#JavaScript Syntax
JavaScript Programs
A computer program is a list of "instructions" to be "executed" by the computer.
In a Programming language, these program instructions are called statements.
JavaScript is a programming language.
JavaScript statements are separated by semicolons:
JavaScript Statements
JavaScript statements are composed of Values, Operators, Expressions, Keywords, and Comments.
JavaScript Values
The JavaScript syntax defines two types of values: Fixed values and variable values.
Fixed values are called literals, Variable values are called variables.
JavaScript Literals
The most Important rules for writing fixed values are:
Numbers are written with or without decimals.
Strings are text, written within double or single quotes.
JavaScript Variables
In a Programming language, variables are used to store data values.
JavaScript uses the var keyword to declare variables.
An equal sign is used to assign values to variables.
In the picture of the JavaScript Programs, x is defined as a variable. Then, x is assigned the value 5.
JavaScript Operatiors
JavaScript uses arithmetic operators such as +,-,*,/ to compute values.
and uses an assignment operator ( = ) to assign values to variables.
JavaScript Expressions
An expression is a combination of values, variables, and operators, which computes to a value. The computation is called an evaluation.
The values can be of various types.
JavaScript Comments
Not all JavaScript statements are "executed".
Cod after double slashes // or between /* and */ is treated as a comment.
Comments are ignored, and will not be executed.
JavaScript Identifiers
Identifiers are names.
In JavaScript, Identifiers are used to name variables.
The rules for legal names are much the same in most programming languages.
In Javascript, the first character must be a letter, an underscores(__), or a dollar sign($).
Subsequent characters may be letters, digits, underscores, or dollar signs.
Numbers are not allowed as the first character.
This way JavaScript can easily distinguish identifiers from numbers.
JavaScript is Case Sensitive
All JavaScript identifiers are case sensitive.
The variables lastName and lastname, are two different variables.
JavaScript Character Set
JavaScript uses the Unicode character set.
Unicode covers (almost) all the characters, punctuations, and symbols in the world.
No comments:
Post a Comment