• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaScript Coding Convention

 
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic