3. Array. Standard library

Time:2021-1-22

1. Number, string, Boolean

Var a = number (1) — returns the number 1

Var B = string (false) —- return string ‘false’

Var C = Boolean (1) – ——– returns Boolean value true (5 false values: 0, Nan, ”, undefined, null)

The above three declaration methods all return basic types

var a = new number( 1 )

var b = new string( false )

var c = new boolean( 1)

The above three types return objects (hash)

2. Object (array and function)

Note: the inconsistency of arry

Var a = array (3) —- generate an array of length 3, in which there are three undefined values, that is {,} ——– inconsistency is reflected when there is only one value, and two or more arrays are generated normally

Var a = array (3,3) —- generate an array of length 2, that is {3,3}

Var a array (3,3,3) —- generate an array of length 3, that is {3,3,3}

 

 

 

———————————————————————————————————-

 

 

 a.__proto__ === Array.prototype

Array.prototype Is the public property of array

 

Function (with or without new)

var f = function(a,b){

  return a + b

  }

var f = new Function(‘a’, ‘b’ , ‘return a + b’)