IT SOLUTIONS
Your full service technology partner! 
+Expand
   ► KBWebsite Scri...JavaScript a...   Print This     
  From the March 2016 Issue of Prestwood eMag
 
JavaScript and AJAX:
JavaScript Similiar to C
 
Posted 17 years ago on 3/1/2008
JavaScript Q&A Flashcard:
 A flashcard from our JavaScript Flashcards Library
 A FAQ from our JavaScript FAQ Page

KB100904

Question: How is JavaScript syntax like C / C++?

Answer:
The languages have enough in common to make learning one easy if you know the other. By the same token, the differences are subtle enough to trip up those proficient in both. Here's a short list comparing C and JavaScript:
  • Terminating JavaScript command lines in semicolons is optional; in C it's mandatory. Recommended practice is to use them religiously in both languages (and Java as well).
  • Both JavaScript and C are case-sensitive; 'doThis' is different from 'DOTHIS'. Experienced programmers learn to love this feature, which drives beginners nuts.
  • Both JavaScript and C are block-structured computer languages and employ curly brackets -- '{' and '}' -- to delimit blocks.
  • Both JavaScript and C employ quotation -- enclosure in single or double quote marks -- to designate text strings.
  • Arrays in both JavaScript and C are zero-based; the first element is myArray[0], not myArray[1].
  • Both JavaScript and C employ '==' for comparison, '=' for equality, and '!' for negation. In fact the set of JavaScript operators is essentially borrowed from C (right down to the deprecated ternary construct a ? b : c).
  • Both JavaScript and C employ the symbols /* to designate a comment */. JavaScript also permits the use of '//' for short comments, as in C++.

Finally, JavaScript's statements are a strict subset of C++'s, offering a smaller selection of identical looping and conditional constructs.



Comments

0 Comments.
Share a thought or comment...
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P195A1
Enter key:
FAQ Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

 KB Article #100904 Counter
10832
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2025 Prestwood IT Solutions.   [Security & Privacy]