→ JavaScript Style

01 April 2010

I know that when you write Ruby or Python, you use under_scored method names and CamelCase class names. But JavaScript isn't Ruby or Python.

Consider:

  • In browsers, all methods are camelCase.
  • In node.js's standard library, all methods are camelCase.
  • In commonjs, all methods are camelCase.
  • In jQuery, all methods are camelCase.
  • In MooTools, all methods are camelCase.
  • In Prototype, all method are camelCase.
  • In YUI, all method are camelCase.
  • In JavaScript: The Good Parts, all methods are camelCase.

I'm not saying you must write JavaScript a certain way. Do what makes you the most comfortable, write code that is fun to write. But if you're trying to figure out what everyone else is doing, they're doing camelCase.