Introduction
I believe there are a lot of people like me are halfway front-end development, when it is to find a training institution to train a four or five months out to find a job, so the basic part of the front-end Js mastery is very weak, although the work is found, but in the daily work of many problems encountered do not know how to solve or do not know how to generate, are not firm foundation, so I want to turn comb front-end JS basic part, also recorded, remember to write a note may deepen their understanding and memory, but also hope to help students in need;
I am also watching the video while combing, see where combing to where, but also will continue to slowly improve. There are incomplete places or incorrect places welcome to point out the discussion. Thank you ~
1.Create variable way of
Definition of a variable as a container for storing specific values, the stored values can be changed at any time;
1 | 1. var name = 'name'; create variable |
2. Data type
1 | Basic data type. |
1 | Introduce data types. |
1 | Symbol (es6's new base data type) unique value |
3. Digital type
Type conversion
1 | Conversion by Number() method |
1 | Reference type |
Parsing string numbers
1 | find a valid number starting from the leftmost character of the string and convert it to a valid numeric character, ending the search when a non-valid numeric character is encountered; |
Comparison of NaN
NaN is not equal to anyone, including itself; if (NaN == NaN) => false.
Boolean types
true and false have only two values; true = 1 false = 0;
Only 0, null, undefined, NaN, and empty string are false in js, the rest are true
5.null && undefined
null means null object pointer
undefined means undefined
6. Common methods for arrays
- push => Add new content to the last item of the array. The return value is the length of the array after adding;
- pop => Delete the last item of the array. The return value is the content of the deleted item;
- shift => Delete the first item of the array. The return value is the content of the deleted item; 4. unshift => Add new content to the start of the array. The return value is the length of the array after it is added;
- splice
delete arr.split(n, m)
Delete m contents from index n. Returns a new array with the contents removed; if m is not passed, the array is removed from n to the end of the array;
Add arr.split(n, 0, m)
remove 0 items from index n and add m items to the front of index n; returns the empty array;
Modify arr.splice(n , m , x)
start from index n, delete m items, insert x items in front of n; return to delete the array.slice
slice(n, m) from the index n, find the index m, excluding the index m; return to find the new array
7.concat
splice array, you can spell value or array; return value is a new array of splice
1 | let arr1 = [1, 2, 3], arr2 = [11, 22, 33]; |