JavaScript basic type, data type

1. basic types: undefined, null, Boolean, Number The, String, Symbol

  Undefined type: a variable has not been assigned will have a default value undefined;

  Null Type: null only one type of value null;

  Boolean: boolean represents a logical entity that can have two values: to true and false;

  Digital Type: floating-point addition can represent, there are some signed value, + Infinity, -Ifinity and NaN ( non-numeric ) ;

  String types: type used to represent text data, each element of the string occupies the position of the string,

  Index of the first element is 0 , the next index is 1 .

  Type Symbol: symbol type is unique and can not be modified.

2. Data type: numeric, string, array (reference type), an object (reference type).

  Object and can be divided into three subclasses

    1. The narrow object ( Object )

    2. Array ( Array )

    3. function ( function )

    3.typeof and instanceof roles and differences

    instanceof and typeof it can be used to determine whether a variable is empty or what type of variable.

    typeof to acquire a type of variable, returns the result: Number, Boolean, String, function

       objcet, undefined, for the array, null other special object using typeof a rate of return objcect .

     typeof 123 === 'numer' // determines whether the number

     typeof '123' === 'string' // determines whether a string

     typeof true === 'boolean' // determines whether a Boolean value

     typeof a === 'function' // determines whether a function

  instanceof for determining whether a variable is an instance of an object, such as A = new new the Array () ;

    alert (a instanceof Object) returns true, while alert (a instanceof Object) will

    Return true, because Array is an object subclass.

 4. The value of the basic data type of the stack is present, complex data types are stored in stack addresses, when the basic type as an argument to a function, the function does not change its value changed outside,

  When the complex data type as an argument to a function, its internal function to modify the value of the external variable parameter values.

The memory is divided into four areas: the stack area (Stack), heap, static global zone read-only region (code region and constant region)

     JavaScript basic type, data type

      

Guess you like

Origin www.cnblogs.com/nmxs/p/11782434.html