• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaScript Coding Convention

 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends, my name is Jeffry. I'm new in here. I'm also new in Javascript. I want to know if the javascript has coding convention like Java programming language. does it has coding convention?


thanks

Jeffry Kristianto Yanuar
SCJP 5.0
SCJA
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be honest, I've never heard of one. A lot of the common sense conventions carry over from Java, but were there specific areas you were wondering about?
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be honest, I've never heard of one. A lot of the common sense conventions carry over from Java, but were there specific areas you were wondering about?


I have the book titled Sams Teach YourSelf JavaScript in 24 Hours. the author always create a method with a capital letter in the first letter. it confused me very much. There are no gap between variable asignment for example:




Does the javascript programmer code like above in the real project?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Umm, well, I never had much respect for Sam's books....

In any case, I've never seem cap letters used for function names. Similar to Java, identifiers (be they functions or otherwise) are customarily created in camel case with an initial lowercase letter. JavaScript "classes", as in Java, start with a capital letter, and so on.

With regards to whitespace, I've seen lots of variations. I tend to use whitespace to make code more readable, but I don't think that there's one prevalent convention.
[ May 13, 2008: Message edited by: Bear Bibeault ]
 
Jeffry Kristianto Yanuar
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it will be best if I simply use Java coding convention. I like SAMS 24 hours books because the book provide a faster way to learn. Thanks for replying.


Jeffry Kristianto Yanuar


SCJP 5.0
SCJA
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic