Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

What Are the Most Popular JavaScript Keywords? and What This Means for ECMAScript 6

DZone's Guide to

What Are the Most Popular JavaScript Keywords? and What This Means for ECMAScript 6

· Web Dev Zone
Free Resource

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda

Ariya Hidayat has used his Esprima parser to count the most popular keywords in a corpus of JavaScript libraries.

The five most popular ones are (by far):

  • 19.2%: this
  • 18.5%: function
  • 18.2%: if
  • 17.1%: return
  • 12.6%: var
Quoting a comment by Thomas Fuchs:

As an interesting aside, CoffeeScript eliminates two out of the first five completely (return and var), and has much shorter ways to express function (->) and this (@).

Functional-programming-style implicit return of the last value in a block is indeed a good idea and will probably make it into ECMAScript 6 in one form or another. One should not forget that the brain recognizes tokens, not characters, which means that for reading code (which is much more important than writing code), shorter tokens don’t matter much. That being said, a shorter function notation will probably also be part of ECMAScript 6 and is appreciated. I do like that JavaScript has a keyword for declaring variables (var now, let soon), because that helps with checking for typos.

For more information, including a diagram of the distribution of the keywords, consult Ariya Hidayat’s article.

Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda

Topics:

Published at DZone with permission of Axel Rauschmayer, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}