JavaScript syntax is a set of rules that defines the structure of the JavaScript language.
var X, Y; // how to declare variables X =. 7; Y =. 8; // how assignment Z = X + Y; // how Calcd
JavaScript value
JavaScript value statement defines two types: mixed and variable values.
Mixing value is called literal (literal). Variable value is called variable.
JavaScript literals
Written in a mixture values most important rule is:
Write value with or without decimal point can be:
15.90 10011
The text string is surrounded by a double or single quotes:
"Bill Gates" 'Bill Gates'
JavaScript Variables
In programming languages, variables are used to store data values.
Using JavaScript var keyword to declare variables.
= Number used to assign values to variables.
In the present embodiment, x is defined as a variable. Then, x is the assigned value is 7:
There x; x = 7;
Operators JavaScript
JavaScript uses arithmetic operators ( + - * /) to calculate the value:
(7 + 8) * 10
Value can be of various types, such as numbers and strings.
For example, "Bill" + "" + "Gates", is calculated as "Bill Gates":
"Bill" + " " + "Gates"
JavaScript Keywords
Key words used to identify the JavaScript action to be performed.
var keyword tells the browser to create a new variable:
where x = 7 + 8 ; where y = x * 10;
JavaScript comment
Not all JavaScript statements are "executed."
Double slash // or / * code * / between and are treated as comments.
A comment will be ignored and will not be executed:
var X =. 7; // executes // var X =. 8; not performed
JavaScript identifier
Identifier is the name.
In JavaScript, an identifier for the named variable (and a keyword, a function and label).
In most programming languages, the rules are mostly the same legal name.
In JavaScript, the first character must be a letter, underscore (-) or dollar sign ($).
A series of characters can be letters, numbers, underscores or dollar sign.
Tip: Value can not be used as the first character. In this way, JavaScript can easily distinguish between identifiers and values.
JavaScript is case sensitive
All JavaScript identifiers are case sensitive.
Variable lastName and lastname, are two different variables.
lastName = "Gates";
lastname = "Jobs";
JavaScript does not VAR or translated keyword Var var.
JavaScript and camel case
Historically, programmers had to use three methods to a variable name multiple words connected:
Hyphen:
first-name, last-name, master-card, inter-city.
Notes: JavaScript can not use a hyphen. It is reserved for the subtraction.
Underline:
FirstName, LastName, MasterCard, InterCity.
JavaScript programmers tend to use camel case with a lowercase letter began:
firstName, lastName, masterCard, interCity
Source: soft Technology www.sysoft.net.cn