About array:
Array is a commonly used JS structure. marked .. you can use the following method to traverse objects. to delete an array, you must use splice (subscript to delete several values). to delete an array, the element is splice (index, 1 ).
For array traversal, you can delete multiple values that meet the conditions. You can traverse the values from the back to the front and then delete the values. This ensures that the subscript variables are effective.
Declare an array: var arr = [];
Insert value to array: arr. Push (1 );
Delete an element arr. splice (subscript, number of items deleted );
Clear all the elements directly. Arr = NULL; or if it is assigned to something else, the array will be deleted. If it is reset, arr = [];
Traverse all elements. You can use the in syntax of for. You can also use for with the subscript of a variable to traverse. For (var iter in ARR) {console. Log (ITER );}
Number of elements in the array: arr. length;
About the JS dictionary:
JS dictionary .? It's really a mess .... OBJ is actually a dictionary .. for example, VAR opacket ={} declares an opacket variable .. then opacket ["mm"] = "login" and opacket. mm = "login" is equivalent. in other words .. this "dot Syntax ". it is the convenient Writing of the JS dictionary .... you can try this feature more. very convenient.
For the traversal of all methods of an object, you can use the in method of for to traverse. For (var iter in dict) {console. Log (ITER )}.
Delete a variable. or a function or an element. (haha. JS is so amazing. OBJ and dictionary are two things. the concept is missing. convenience. good understanding !). Delete opacket ["mm"] or delete opacket. Mm
Add something to the map. Click the name next to it and you will be OK. Or [name.
VaR dict ={}; dict. Mm = "Hello! "; Dict [" value "] =" world! "; For (var iter in dict) {console. log ("Key =" + ITER + "value =" + dict [iter]);} Delete dict. mm; // delete dict ["value"];
Judge whether the key exists in the dictionary: If (key in dict) {In} else {not in}
Determine the number of elements in the dictionary or object: object. Keys (dict). Length