JavaScript (two) - the type of data, flow control, Map and Set

1. Data Type

1.1 String

  • We used a regular string single quotes, or double quotes package
    (1) escape character
    Here Insert Picture Description
    (2) Multi-line string written : the ` (in quotes esc key on the keyboard)
    Here Insert Picture Description
    (3) template string
    Here Insert Picture Description
    (4) string length
    str.length

    Here Insert Picture Description
    console output
    Here Insert Picture Description
    (5) of the string variability: immutable
    Here Insert Picture Description
    (6) case conversion
    Note: this is a method , not a property of
    student.toUpperCase ()
    student.toLowerCase ()

    Here Insert Picture Description
    (. 7) acquires the specified index
    str .indexOf ()

    Here Insert Picture Description
    (. 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
    Here Insert Picture Description

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
Here Insert Picture Description
(2) obtained by the subscript index arr.indexOf element ()

Here Insert Picture Description
Portion (3) taken array and returns a new array arr.slice ()
similar to the substring (), containing free end of the head

Here Insert Picture Description
(4) push (), pop () tail
push: press-fitted to the rear
pop: a pop-tail element
Here Insert Picture Description
(5) unshift (), shift () Head
unshift: press-fitted to the head
shift: a pop-up head element
Here Insert Picture Description
(6) Sort Sort ()
Here Insert Picture Description
Here Insert Picture Description
(. 7) inverted elements reverse ()
Here Insert Picture Description
(. 8) splice concat ()
Note: concat () does not modify the array, but will return a new array
Here Insert Picture Description
(9) connector join ()
Print splicing array using a specific string concatenation
Here Insert Picture Description
(10) multi-dimensional array
Here Insert Picture Description

1.3 Object

A plurality of key-value pairs , all the keys are strings , the value of any object .
Here Insert Picture Description
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
Here Insert Picture Description
object properties (2) does not exist, no error
Here Insert Picture Description
(3) deletion of the dynamic properties
Here Insert Picture Description
(4) dynamically add attributes
Here Insert Picture Description
(5) determines whether the object exists in the property
Here Insert Picture Description
(6) determining a property whether it is owned by the object itself
Here Insert Picture Description

2. Process Control

(1) if judgment
Here Insert Picture Description
Here Insert Picture Description
(2) while loop
Here Insert Picture Description
Here Insert Picture Description
(3) for cycle
Here Insert Picture Description
Here Insert Picture Description
(4) forEach loop
Here Insert Picture Description
Here Insert Picture Description
(5) for ... in loop
Here Insert Picture Description
Here Insert Picture Description

3. Map and Set

New features for ES6

(1) the Map
Here Insert Picture Description
Here Insert Picture Description
(2) the Set: unordered collection of unique
Here Insert Picture Description

4. iterator

of ... for (ES6 new features) can be used to traverse the Array, the Map, Set
(. 1) to iterate the Array
Here Insert Picture Description
Here Insert Picture Description
(2) traversing the Map
Here Insert Picture Description
Here Insert Picture Description
(. 3) traversing Set
Here Insert Picture Description
Here Insert Picture Description

Published 62 original articles · won praise 2 · Views 2742

Guess you like

Origin blog.csdn.net/nzzynl95_/article/details/103907020