Article Directory
1. Data Type
1.1 String
- We used a regular string single quotes, or double quotes package
(1) escape character
(2) Multi-line string written : the ` (in quotes esc key on the keyboard)
(3) template string
(4) string length
str.length
console output
(5) of the string variability: immutable
(6) case conversion
Note: this is a method , not a property of
student.toUpperCase ()
student.toLowerCase ()
(. 7) acquires the specified index
str .indexOf ()
(. 8) taken string
str.substring (. 1) // string taken from the first to the last string
str.substring (l, 3) // [l, 3) containing free end of the head
1.2 Array
Array can contain any type of data
var ARR = [1,2, 'X', 4, 53, "Student"];
(. 1) length arr.length
Note: Add to arr.length assignment, array size will change, if the assignment is too small, the element will be lost
(2) obtained by the subscript index arr.indexOf element ()
Portion (3) taken array and returns a new array arr.slice ()
similar to the substring (), containing free end of the head
(4) push (), pop () tail
push: press-fitted to the rear
pop: a pop-tail element
(5) unshift (), shift () Head
unshift: press-fitted to the head
shift: a pop-up head element
(6) Sort Sort ()
(. 7) inverted elements reverse ()
(. 8) splice concat ()
Note: concat () does not modify the array, but will return a new array
(9) connector join ()
Print splicing array using a specific string concatenation
(10) multi-dimensional array
1.3 Object
A plurality of key-value pairs , all the keys are strings , the value of any object .
Js objects, ...... {} represents an object, the description key attributes xxxx: xxxx, separated by commas using a plurality of attributes, the last property by a comma.
(1) Object Assignment
object properties (2) does not exist, no error
(3) deletion of the dynamic properties
(4) dynamically add attributes
(5) determines whether the object exists in the property
(6) determining a property whether it is owned by the object itself
2. Process Control
(1) if judgment
(2) while loop
(3) for cycle
(4) forEach loop
(5) for ... in loop
3. Map and Set
New features for ES6
(1) the Map
(2) the Set: unordered collection of unique
4. iterator
of ... for (ES6 new features) can be used to traverse the Array, the Map, Set
(. 1) to iterate the Array
(2) traversing the Map
(. 3) traversing Set