preface
Working from home for two weeks, in a quiet home, suitable for enlightenment, think into the line more than three years, every day in every day in the technology, the pursuit, to study various frameworks, libraries, but don’t know, they are all based on JavaScript, although feel every day in learning, but eventually found only in the work practice peace scattered learning, I think I know a little bit about everything. But finally can not rule, so in last year’s face try lian all problems exposed.
1. Lack of front-end basic knowledge, many things know why
2. It is difficult to learn new knowledge due to its weak foundation
There is no strong point in technology, and there is a short board, there is no one can take the ability to segment the field
3. Few wheels and little personal practice make it difficult to connect scattered knowledge, resulting in a lack of ability to solve problems
Turn and change to realize, before all, are floating clouds, decided to learn the front end, with this article, record one or two, wrong place, also please big guy advice!
Books recommended
The first is the Red Book JavaScript Advanced Programming, followed by the Big rhino JavaScript Authority Guide, which is not for you to read, but for you to check out, and then the Deep Understanding of ES6, Diagrams HTTP, CSS Revealed, etc. If you want an electronic version, please send a private message.)
How to learn
Thanks to the industry’s leading men, excessive energy, embrace knowledge to pay, so that we have a glance at their learning methods, all eyes, very happy, finally do not have to mine their own pit. Here’s how they learn:
1. The first and most important method is to establish knowledge structure, which helps us organize scattered knowledge
2, trace back to the source, know why, to remain curious, in addition to solving problems, but also know why to write
Begin to learn
First on a map and taobao bosses do before the photo front knowledge architecture diagram, we can according to this map route to reframe the knowledge points, thank the class of people… (though spent money), then, we follow the diagram, referring to the class of bosses, began to relearn the front-end (also a study notes)!
javaScript
Js has a very popular definition: specialized programming web interaction language, and JS is divided into data structure, and the execution process, the so-called data structure, is the data type, and instances, and the so-called execution process is algorithm. Js can be analyzed from the perspective of runtime, grammar and execution process. Let’s tackle each one of them.
The runtime
Runtime is when the code executes, and the execution is dependent on data types
type
Js specifies seven basic types, including six primitive types and one reference type
The original types are: 1. Number
2, the string
3, undefined
4, Boolean
5. Null (controversial)
6, Symbol (es6 added)
Reference types include:
7, the object
In the basic category, many of the classic interview questions were thrown out, but did you not answer them neatly?
What is the difference between null and undefined? Null means defined but empty, while undefined means unassigned. Unlike undefind, null is a JS keyword and cannot be tampered with. However, undefind was originally designed as a variable. In general we use void 0 to get the value of undefind
0.1+0.2 is equal to 0.3.
The answer is fales, the two sides are not equal, which is actually a feature of floating point operation. These decimals will be converted into floating point numbers represented by binary scientific notation, and when converted to IEEE 754 standard representation, there will be an infinite number of cases in this middle, so that the accuracy problem, the correct way is to use the minimum accuracy provided by JS
0.1 + 0.2 0.3 < = Number. EPSILON / /true
Copy the code
Type conversion
Because JS is a weakly typed language, there are frequent type conversions.
Type conversions when performing comparisons
Implicit conversion will happen in operation, and there will be some rules, default: everything is converted to digital, then compared or operation, of course, there will be some special cases such as string concatenation can be accomplished by the plus sign, such as if the two are strings, in comparison is not converted to digital, but directly compare unicode, if top exactly the same, For example, if the value of a reference object is null, the value of a reference object is null. If the value of a reference object is null, the value of a reference object is null
[] = [] / /false{}+[] //, a typical type conversion result, interested can check, the process is quite complex, no further detailsCopy the code
The transformation using the
Believe that as a front-end developer you will be very curious, why a basic types can call to the method, actually each basic type has a corresponding class, and when we invoke primitive types, he will automatically invoke primitive type corresponding class, converts it into a corresponding object, this is called the transformation, using the And after each transformation properties has a private class, and have provided by the js Obiect. Prototype. ToStriing to obtain, that is why we often use this method to judge data types, because he compared to typeOf, Instanceof can accurately determine the type of each class
Unboxing conversion
With packing, it must be split open a case, after the original type packing execute after the operation, must have the devanning process to get we need the original type of value, in fact, the so-called devanning personal understanding is by calling the object after the valueOf and using the toString method to achieve transform objects into primitives, so someone will ask again, The toString method is used to retrieve the class and unbox it. Most primitive types override the toString method for the corresponding class. Instead of finding the Object according to the prototype chain, the toString method of the corresponding class is called.
Declare a variable
What is a variable? It’s essentially. ** A segment of memory with a name
So how do you declare variables there are five ways that I know of so far
1, the var
Declare variables. Undefined can be read before assignment. There will be statements in advance
2, let
Declare variables. Cannot be read before assignment. i.
3, const
Declare constants. Do not write. If it is a reference type, you can use js methods to manipulate the values inside the reference type
4, the function
Declare variables. Point to a function
5, class
Declare variables. This variable points to a class, the constructor.
Clear declaration variables and we’re looking at some classic interview questions
var letWhat's the difference between const? 1.letDeclared variables have block-level scope. 2,letThe declared global variable is not an attribute of the global objectfor (letx...) The loop creates a new binding for x at each iteration.letConst cannot be defined repeatedlyCopy the code
The assignment
We all know that assignment is executed from left to right, so how do we do continuous assignment? At this point you must hesitate, let’s look at a problem.
var x=y=100 console.log(x); //100 console.log(y); / / 100Copy the code
The answer is obvious, it is 100, and can save the code, but why there is no such use, it involves a js legacy of hole, variable leak problem, lead to global pollution, rule is if you don’t exist to a variable assignment, in the global automatically created, y = 100 here is actually in the global automatically created. Relearn front end (1) come to an end.