/ * * * Five basic data types: String, Number, Boolean, null, undefined * / // undefined // declare variables foo, undeclared variable bar var foo; the console.log ( ` typeof foo: foo $ {}` , ` typeof bar: bar {} $`); // typeof foo: bar typeof undefined: undefined IF (foo === undefined) { // foo congruent undefined the console.log ( 'foo congruent undefined' ); } the else { the console.log ( 'foo insufficiency equal undefined' ); } IF ( typeof bar === 'undefined') { // bar congruent undefined console.log ( 'bar congruent undefined' ); } the else { the console.log ( 'bar is not identical to undefined' ); } // typeof return string type the console.log ( ` typeof ( typeof foo): $ { typeof ( typeof foo)} `); // typeof (typeof foo): String // definition of function f (), but not the function thereof, the default is undefined function f () {} the console.log (` typeof f (): $ { typeof F ()} `,` F () === undefined: $ {F ()} `=== undefined); // typeof F (): F undefined () === undefined: to true // null the console.log ( ` typeof Null: $ { typeof Null}`); // typeof Null: undefined the console.log ( ` typeof null : $ { typeof null }`); // typeof null: Object // String // Common escape character // --------------------------------------------- ------------------------------ // \ n-newline // \ T tab // \ space B // \ Enter r // \ F website page // \\ backslash // \ 'single quote // \ "double quotes // \ 0nnn nnn octal representation of the character code (n is 0-7 in an octal number) // character \ xnn hex code nn represented (n is 0 to F in a hexadecimal number) // \ unnnn hexadecimal representation of the Unicode character code nnnn (n is 0 to F in a hexadecimal number) // ------------------- -------------------------------------------------- ------ var foo = 'Hello' ; the console.log ( ` typeof foo: $ { typeof foo}`); // typeof foo: String // Boolean var right = to true , Wrong = to false ; the console.log ( ` typeof right: $ { typeof right},typeof wrong: ${typeof wrong}`); // typeof right: boolean, typeof wrong: boolean // number // 整型 var foo = 100; console.log(`typeof foo: ${typeof foo}`); // typeof foo: number // 八进制 var foo = 017; console.log(foo); // 15 // 十六进制 var foo = 0xAB; console.log(foo) // 171 // 浮点数 var foo = 23.01; console.log(foo); // 23.01 // maximum value of the console.log (Number.MAX_VALUE = $ { `` Number.MAX_VALUE}); // Number.MAX_VALUE 1.7976931348623157e + = 308 // minimum console.log ( `Number.MIN_VALUE = $ { } `Number.MIN_VALUE); // Number.MIN_VALUE = 5E-324 // positive infinity the console.log (as Number.POSITIVE_INFINITY = $ {` `as Number.POSITIVE_INFINITY}); // as Number.POSITIVE_INFINITY = infinity // negative infinity console .log (as Number.NEGATIVE_INFINITY = $ { `` as Number.NEGATIVE_INFINITY}); // as Number.NEGATIVE_INFINITY = -Infinity // isFinite limited number verification var foo = as Number.POSITIVE_INFINITY, bar = foo. 3 * ; IF (isFinite (bar)) { // bar infinite numbers console.log ( 'bar is a limited number' ); } the else { the console.log ( 'bar infinite numbers' ); } // NaN3 not a number , specific values can not be used to directly calculate var foo = 'Hello' ; IF (isNaN (foo)) { // foo not a number console.log ( 'foo not a number' ); } the else { the console.log ( 'foo is digital ' ); }