as a single line comment and is ignored by JavaScript. Any text between the characters “ /* */” is also treated as a multiline comment. • JavaScript uses the semicolon (;) to separate statements. Many JavaScript programmers use semicolons to explicitly mark the ends of statements.
• A literal is a data value for variable that appears directly in a program. • An identifier is simply a name. In JavaScript, identifiers are used to name variables, functions and to provide labels for certain loops in JavaScript code. • In JavaScript certain keywords are used as reserved words, These words cannot used as identifiers in the programs .
JavaScript Variables: Variable is a memory location where value can be stored. Variable is a symbolic name for a value. Variables are declared with the var keyword in JavaScript. Every variable has a name, called identifier.
. . Basic Data types and Declaring variables: Every variable has a data type that indicates what kind of data the variable holds. The basic data types in JavaScript are Strings, Numbers, and Booleans.
• A string is a list of characters, and a string literal is indicated by enclosing the characters in single or double quotes. Strings may contain a single character or multiple characters, including whitespace and special characters such as \n (the newline). • Numbers can be integer or floating-point numerical value and numeric literals are specified in the natural way. • Boolean can be any one of two values: true or false .
Boolean literals are indicated by using true or false directly in the source code. Variables are declared in JavaScript using var keyword that allocates storage space for new data and indicates to the interpreter that a new identifier is in use. Declaring a variable in JavaScript as follows: var no; var no1,no2; The var no; statement tells the interpreter that a new variable no is about to be used and var no1,no2 ; tells the interpreter that no1 and no2 are variables. .
. Rules for naming variable . The first character must be a letter or an underscore (_). Number cannot