Skip to content

Instantly share code, notes, and snippets.

@honza
Created July 12, 2011 14:29
Show Gist options
  • Save honza/1078088 to your computer and use it in GitHub Desktop.
Save honza/1078088 to your computer and use it in GitHub Desktop.
What looks best?
/*
* How do you like your Javascript variables?
* Is there a PEP8 for Javascript?
*/
// Option 1
var viewPage = function() {};
// Option 2
var view_page = function() {};
// Option 3
var ViewPage = function() {};
@exallium
Copy link

Situation wise, I'd say first one for object instance, second one for function/variable names, and third one for class names.

However I like the second one best for plain old variables.

@honza
Copy link
Author

honza commented Jul 13, 2011

Option 3 is for classes. Option 1 is for everything else. I think this is the norm.

What you're describing seems to be Python. :)

@exallium
Copy link

Yep, in Python I'd use 2 and 3
In Java, C# or C++ I'd use 1 and 3
In C I'd just use 2

In Javascript, I'd probably still just use 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment