Hacker News new | ask | show | jobs
by Segmentation 4586 days ago
> The clear convention in JavaScript is camelCase, why switch away from it?

Citation?

5 comments

Let's just try some searches for some common names using github code search with a ".js" extension filter

hideImage vs hide_image: 424 vs 50

toggleItem vs toggle_item: 1022 vs 52

clickElement vs click_element: 3469 vs 368

Coding conventions by statistics :)

https://github.com/search?q=searchPage+extension%3Ajs&type=C...

How would you even expect this to be cited?

Seriously, does someone need to crawl every Javascript project on Github and compile statistics on naming styles before they can make an obviously true statement like this? The fact that camelCase is the norm in the language and browser environment is obvious to anyone who has written even a modest amount of JS.

   notQuantified != false
notQuantified !== false

to avoid type coercion here

S/he was using CoffeeScript, obviously! :)
> crawl every Javascript project on Github and compile statistics on naming styles

You mean... like this? http://sideeffect.kr/popularconvention/#javascript

Unfortuantely there's no stat there for camelCase for Javascript.

> Citation?

Well, it's sure as hell not window.set_timeout, window.clear_interval, window.on_load, etc.

Javascript was created in camelCase, and most major open source projects I've used have been camelCase. I can't find any data on it, but it fits with my experience for what that's worth.
Suggestion:

JavaScript.

Camel cased would actually be javaScript
Idiomatic JavaScript code uses both PascalCase and camelCase.

Constructors use PascalCase; variables and methods use camelCase.

So, it's OK to call it JavaScript! :-)