The template string 1, JavaScript does not distinguish between integers and floating-point numbers, is uniformly represented by number.
2. NaN
This special number is not equal to all other values, including itself:
Nan===nan; False
The only way to judge NaN
is through the isNaN()
function:
IsNaN (NaN); True
3 null
. Represents an "empty" value, which, 0
unlike an empty string ‘‘
, 0
is a numeric value that ‘‘
represents a string of length 0 and null
represents "null". The undefined
expression value is undefined.
4. JavaScript arrays can include arbitrary data types.
[1, 2, 3.14, ' Hello ', NULL, true];
Another way to create an array is through a Array()
function:
New Array (1, 2, 3); Array created [1, 2, 3]
5. The way to enable strict mode is to write on the first line of the JavaScript code:
6, because the multi-line string to \n
write up more trouble, so the latest ES6 standard added a multi-line string representation method, with anti-quote ' ... ' means:
' This is a multi-line string ';
The results of the operation are as follows:
7. Template string
To concatenate multiple strings, you can connect them with a +
number:
var name = ' Xiaoming '; var age = 20;var message = ' Hello, ' + name + ', you are this year ' + Ages + ' old! '; alert (message);
If there are many variables that need to be connected, +
it is more troublesome to use the number. It is convenient to use ES6 template strings.
var name = ' Xiaoming '; var age = 20;var message = ' Hello, ${name}, you ${age} year old! '; alert (message);
The result is exactly the same:
8. JavaScript provides some common methods for strings, note that calling these methods does not alter the contents of the original string, but instead returns a new string:
toUpperCase()
Turn a string into uppercase;
toLowerCase()
Turn a string into lowercase;
Something you have to know about JavaScript.