JavaScript Syntax Basics
In this lesson, we'll cover some JavaScript basics. Let's begin!
We'll cover the following...
Like every language, JavaScript has its own syntax rules.
As you have seen in the samples of this course, JavaScript is one of the “curly-brace languages”, its syntax is similar to C, C++, C#, and Java.
At the time of this writing, most browsers use the fifth edition of the ECMAScript standard (Ecma-262, Edition 5.1/June, 2011), so all syntax rules treated here are based on this standard. Any time JavaScript is mentioned in the context of syntax or semantic rules, the ECMAScript standard is used.
JavaScript is case-sensitive, so every token including keywords, function names, variables, object names, and operators make a distinction between lowercase and uppercase letters.
For example, the new operator (“new
” is a keyword) is different from New
which may be an identifier, just as myNumber
is a totally different variable name than Mynumber
.
When the JavaScript engine parses the script, it first scans for smaller elements like keywords, identifiers, operators, comments, literals, etc. To understand the rules of the languages, it is worth getting to know the syntax of these smaller units.