Set of rules, you should follow to write an Identifiers:
- The first character of an identifier should be letters of the alphabet or an underscore (_) or dollar sign ($).
- You can use letters of alphabets or digits or underscores (_) or a dollar sign ($) to an Identifiers.
- Identifiers are case-sensitive. so, name and Name are not the same.
Note: You can’t use Reserved keywords as Identifiers.
Types of Identifiers (based on scope of the identifier and the data which an identifier will hold):
- The data is said to be primitive if it contains an individual value.
- String values are written in quotes, either single or double (like python).
- To access any character within the string, it is important to be aware of its position in the string.
- The first character exists at index 0, next at index 1, and so on.
- Literals can span multiple lines and interpolate expressions to include their results.
- Boolean is a data type which represents only two values: true and false.
- Example: 100, -5, “Cat”, 10<20, 1, 10*20+30, etc. evaluates to true whereas, 0, “”, NaN, undefined, null, etc. evaluates to false.
- When the variable is used to store “no value”, primitive data type undefined is used.
- The null value represents “no object”.
- BigInt is a special numeric type that provides support for integers of random length.
- A BigInt is generated by appending
nto the end of an integer literal or by calling the function BigInt that generates BigInt from strings, numbers, etc.
- A “symbol” represents a unique identifier. You can make use of Symbol() to generate a value of this type.
- Even if various symbols are created with the same description, they are different values. Thus, symbols ensures uniqueness. So the description provided can be considered as just a label.
- Strings and symbols are basically different and should not accidentally get converted to the other one.
- So far you know that symbols remain unique even if they have the same name. But at times, there may be a situation where you may want the symbols with same name to be same entities.
Then use global Symbols.
- The data type is said to be non-primitive if it is a collection of multiple values.
- The ‘key’ of a property is a string or a symbol and should be a legal identifier.
The Array is a special data structure that is used to store an ordered collection, which cannot be achieved using the objects.
- A single array can hold multiple values of different data types.
- Operators are categorized into unary, binary, and ternary based on the number of operands on which they operate in an expression.
Example of typeOf:
⇨ White (blank) spaces in statements are ignored.
- Non-Conditional statements are those statements that do not need any condition to control the program execution flow.
It is similar to java programming.
- ‘for’ loop is used when the block of code is expected to execute for a specific number of times.
- ‘while’ loop is used when the block of code is to be executed as long as the specified condition is true.
- ‘do-while’ is a variant of ‘while’ loop.
- This will execute a block of code once before checking any condition.