[JavaScript basics] a summary of some knowledge points about JavaScript

Time:2020-5-29

Basic data types in JavaScript

 

Data type name data type specification
Undefined There is only one value, that isundefined , declare the initial value of the variable.
Null There is only one value, that isnull , for null pointer, undefined The value of is derivednull Value of.
String From zero or more 16 bitsUnicode Character composition
Boolean There are only two values, namelytrue Andfalse
Number This type usesIEEE754 To represent integers and floating-point numbers.
Object The objects in ECMAScript are actually a collection of data and functions.
Symbol The newly added data type in ES6 represents a unique value.

Among themObject Type containsFunction  Array  Date  RegExp 

Built in objects in JavaScript

Object name Object description
Arguments Function parameter set
Array array
Boolean Boolean object
Date Date object
Error Exception object
Function Function Builder
Math Mathematical object
Number Numerical object
Object Base object
String String object

typeof null The returned result is'object'

Logically, null Value represents a null object pointer, so it returns a'object' , which can also be understood as an early bug of JavaScript, and now the standard is such a specification. V8 has been modified and implemented typeof null === 'null' But it turned out to be impossible.

Array Object method and function

Method name Object description
concat Used to connect two or more arrays and return results, arr1.concat(arr2)
join Put all the elements of the array into a string, and the elements are separated by the specified separatorarr1.join(',')
pop Delete and return the last element in the arrayarr1.pop()
push Adds one or more elements to the end of the array and returns the new lengtharr1.push(1)
reverse Reverse the order of the elements in the array, arr1.reverse()
shift Delete and return the first element in the arrayarr1.shift()
slice Returns the specified element from an existing array
sort Sort elements of an arrayarr1.sort()
splice Delete elements and add new elements to the array
toString Convert an array to a stringarr1.toString()
toLocaleString Convert array to local stringarr1.toLocaleString()
unshift Add one or more elements to the beginning of the arrayarr1.unshift(1)
valueOf Returns the original value of an array object

typeof Possible return values

type Return results
Undefined “undefined”
Null “object”
Boolean “boolean”
Number “number”
String “string”
Symbol (new in ECMAScript 6) “symbol”
Host object (provided by JS environment) Implementation-dependent
Function object ([[call]] is implemented in article ecma-262) “function”
Any other object “object”

Please correct any inaccuracies in the article.

Recommended Today

The way of nonlinear optimization

Mathematical knowledge 1、 Nonlinear functionLinear function is another name of a function of first degree, then nonlinear function means that the function image is not a function of a straight line.Nonlinear functions include exponential function, power function, logarithmic function, polynomial function and so on. 2、 Taylor expansion1. Taylor formula:Taylor’s formula is to add a_ The […]