literals
Literal is a value of any type given explicitly. So in expression x+10, x is variable and 10 numeric literal.
Sign + or - can be consider as part of the numeric literal or as expression with unary + and -.
example | description |
---|---|
undefined | The undefined value means that no value was assigned. For example, you can check if a function argument is passed:
|
23 +23 -23 |
Decimal integer literal is defined as sequence of digits without a leading 0 (zero). |
023 0o23 -023 |
An octal integer literal is defined as sequence of 0-7 digits with leading 0 or prefix 0o. |
0x23 0x23AAbb -0xabcde |
A hexadecimal integer literal is defined as sequence of 0-9 digits and letters a-f or A-F with prefix 0x or 0X. Case of letters is meaningless, so 0xa = 0xA = 10 and 0xf = 0xF = 15 |
-0b0001 -0abcde |
A binary integer literal is defined as sequence of 0 and 1 with prefix 0b or 0B. |
3.1415926 -.1415926 -3.14E+23 .14e-23 |
A floating-point literal is defined by formula
|
true false |
true and false are boolean literals. Do not confuse them with the true and false values of the Boolean object. The Boolean object is a wrapper around the primitive boolean data type. |
[1,2 , 3] [ "a", , "c"] |
An array literal is defined as sequence of values in square braces. When value is omitted, it means an undefined value. |
|
An object literal is a list of zero or more pairs of property names and associated values of an object, enclosed in curly braces. Values also can be object, function or array. |
"str" 'str2' |
A string literal is a sequence of characters in single or double quotes. More details here |
/^\S+@\S+$/ | A regular expression literal is defined as a pattern enclosed between slashes, with possible flags at end
|