Words to say to yourself: Initial learning mentality is holding the solution requirements, can write web attitude to learning, it forms a abuses, is to learn the logic is complicated or difficult knowledge, can produce resistance subconsciously, I felt like I normally use my learn this knowledge, so that there are no serious remember a lot of knowledge Now I should correct my mentality,javascript is the most important knowledge in web front-end development, should hold the mentality to understand this language to learn, seriously treat every knowledge point, programming should improve their own thinking, the following start to review javascript:
The text uses the way of asking oneself to answer to carry on the review, when oneself look at the document, put forward the knowledge point that has seen in the way of asking questions, finally after looking at the document, oneself answer the knowledge point that summarizes the review, in order to strengthen and consolidate knowledge
What kind of language is JS? What does it have?
It's a multigeneric, dynamic language, it contains types, operators, standard built-in objects, methods, and its syntax comes from C and Java, so a lot of the syntax is very similar, it's through the prototype chainCopy the code
What are the types of JS, and what is the difference between a basic data type and a reference data type?
- Basic data types
- The numerical
- Boolean
- string
- Null
- Undefined
- Reference data type
- Object
- function
- Array
- Data, etc.
- Object
A detailed understanding of types in JS
The numerical
parseInt:
- ParseInt () is the built-in function that converts a string to an integer
- ParseInt (X,Y), which takes a second optional argument: the second argument selects the conversion base
- The difference between parseInt and Parsefloat is that parseInt can take a second argument, while Parsefloat does not
- When parseInt() converts a string that is not a number, the return value is NaN
let a = "abc";
let b = parseInt(a);
console.log(b); // NaN
Copy the code
The unit operator +
- Casts a string (including letters) to type Number
let a = "55"; console.log(typeof a); //string console.log(typeof +a); //number let b = "abc"; console.log(typeof b); //string console.log(typeof +b); // number Copy the code
NaN
- NaN participates in the operation, and the result is NaN
console.log(NaN + 1); / / get NaNCopy the code
- You can use the built-in method isNaN to determine NaN
isNaN(NaN); // true
Copy the code
Infinity & -Infinity
// Plus or minus infinitylet a = 1/0;
letb = -1/0; console.log(a); //Infinity console.log(b); //-InfinityCopy the code
string
- There’s a.length method that returns the length of the string
Boolean value
- False: Null, NaN, Undefined, 0, empty string, “”,false these are all false types
- True: All others are true
Undefined
- Variables are allowed to be declared without assignment, but variables that are not assigned are Undefined