This article is the author's personal summary of some of the judging conditions when looking at the Liaoche teacher JavaScript tutorial
null
、
undefined
、
0
、
NaN
and an empty string
‘‘
As
false
, all other values are considered
true
, so the result of the above code condition judgment is
true
Loop 1.for (same c) 2.while (same as C) 3.do while (same as C) Variant for...in Traversal object only Traverse property, no value for property Iterating through an array only iterates through the index, the result is that the string is not numble not 1 is a ' 1 ' so array is also an object, and the index value is its attribute map
Map
Is the structure of a set of key-value pairs with extremely fast lookup speeds. Initialization
Map
Requires a two-dimensional array, or directly initializes an empty
Map
Map method 1.get (key) Get value & nbsp 2.set (key: Value) Add an element 3.h As (key) Find if this key is included return true false  &NBSP ; 4.delete (key) Delete this key A key can only correspond to one value, so the value is placed on a key more than once, and subsequent values will flush out the previous value. set Set is a set of keys, but does not contain Value And key cannot be duplicated Repeat elements are automatically filtered out Add key via delete () to delete key via Add () iterable This is a type &NBS P &NBSP iterating through an array first can take the subscript loop, but traversing the map and set cannot use subscripts. So in order to unify iterable occasional, array,map,set are iterable type Collections that belong to the Iterable type can use For....of ... Loop to traverse Iterate array set value pair value &NBSP ; Traverse map x[0]: Key x[1]: value     &NB sp; for...in and for...of difference &NB Sp for...in traversal is the object's property name & nbsp for...of The value of the object is traversed  &N bsp; for...of only iterates through the collection itself, post-join properties do not traverse &NBSp : iterable built-In a foreach method that receives a function that automatically callbacks the function every time it is iterated , &NB Sp Example: var a = [' a ', ' B ', ' C '];a.foreach (function , array) { // element: point to the value of the current element // index: points to the current index // array: points to the array object itself alert (element);
});
function (element, index, array) This is an anonymous function three parameter names are defined by themselves but the order of the foreach incoming parameters is deterministic, and the separate representation is also deterministic. Executes the function once per iteration down
Map
The callback function parameters are in sequence
value
、
key
And
map
The callback function parameters of the set itself are
element
, Samee
lement
and set itself
JavaScript judgment, Loop, Map, Set