It has been a year since I started to get in touch with JS, and my mind has always been a bit boring. This is also often said in forums. So where is it? I always feel that I am not going deep in learning. Some simple things can be done but cannot be done with ease. Can you tell me more about this bitter talk? They all said, "I cannot tell you how to be specific?
What is unspeakable? You can't say it, but you can't be specific. If you can't put the problem into practice, you can't solve it. This is just a secret! I think this is the "Dilemma" of beginners ". The reason why "I think" is used is to cater to the word "experience" in the title of this article. I am very happy to help you.
Now let's get down to the truth. After thinking back and thinking, I will summarize the following "unspeakable" for beginners. Can you tell us whether we are talking about our secrets.
1. Use system knowledge to embody the problem
We often find that different methods can be used to solve the same problem. For example, to bind a click event to an element, you can use <a href = "#" onClick = "f1 ()"> </a> on an HTML element, at first, we thought this was the method for binding events.
When we see the second time that we can pass a function to an event to bind: a. onclick = f1; then we will think that there is not only one way to bind events.
When addachEvent ("onclick", f1) is used to bind events for the third time, you must think that there are more than three methods to bind events. And there is no reason to do the same thing. there must be three different methods between them?
So what are their differences? How many methods are there to bind events? When you find that a method is incompatible with IE, you still ask why? Is my syntax incorrect? Or what is going on. After one question comes to an end, you have to ask yourself: "Day! When can I learn JavaScript well ?! ".
It may be difficult for you to learn JS well. In fact, you still need to tell you that you are not far from learning well, but you do not know how to go. Why? The reason is that you do not have the system knowledge, because you have not read the JavaScript authoritative guide. He will tell you there are four ways to bind events, and there are two basic methods, all browsers support him. There are two other advanced methods: W3C standard method and IE standard method, so you know why IE is not compatible with one of the advanced methods, right?
Now things are specific. When binding an event, you only need to consider these four methods, and you will not have so many questions. You will also feel that you have understood the incident, and you should understand other problems in the next step. You will also feel that you have finally made progress in JS, and of course you will feel that you are in a difficult situation.
2. Understand the history of JavaScript
Do you know the history of JS? Of course I understand that he was not called JavaScript, and he was not implemented in IE at the earliest. Yes, well said, but this is not the most important thing. Knowing this will not become a master. You must know more details and learn about the history of functional evolution.
Just like above, why are there so many methods for binding events? Why are there so many ways to get an element? Is document. links [] Regular? Or is getElementsByTagName ('A') a bit more formal? Which one has better compatibility? How many other methods are there?
If you know a problem, you have a headache. If you have ten questions, you cannot start. If you have one hundred questions, you will doubt yourself. One thousand questions finally returned to that question "day! When can I learn JavaScript well? This is often the case. The solution is to let him know the specific methods and why. These questions will certainly have answers, because JS is not something left by aliens, it is created by humans, and that person's thinking is limited, isn't it?
When you know that document. links [] is a legacy document method, there are five legacy methods. They are anchors [], applets [], forms [], images [], and links []. Some problems disappear. When you still know that DOM standards keep them, you also know that all browsers support them. You also know that they are called "level 0 DOM" and you will go out of a "dilemma ".
Iii. JS has a cross-cutting Knowledge Structure
The knowledge structure of JS is horizontally and vertically staggered, which increases the difficulty of understanding it and requires a clear understanding of it. The following is an explanation of the "landscape and landscape ".
General knowledge is horizontal. For example, JavaScript is divided into the core part and the client part. This is horizontal. The core part is also divided into lexical structure, data type and value, variables, expressions and operators, statements, objects and arrays, functions, classes, modules and namespaces, and regular expressions. This is also horizontal.
The client can be divided into BOM, DOM, events, styles, forms, etc. These are also horizontal knowledge structures.
A technology rarely uses time as the structure, but because browser development is dynamic, browsers in different periods have different implementations of JS, however, at different times, it is impossible to ignore the web pages written by browsers because of the development of technology, and re-compile all websites with the development of technology, therefore, JS requires development and upgrade, and it also requires forward support. Therefore, even if a better method is available, the previous method must be retained. There are a lot of legacy JS attributes and methods. For example, "level 0 DOM" is retained in the new W3CDOM, to some extent, he is vertical.
When I have a clear understanding of the knowledge structure, one benefit is that when I want to solve a problem, I can know which part of the knowledge I want to use. For example, to obtain the position of an element in the document, you will know that the attribute of the element in the DOM is used. To obtain the position of the mouse pointer, you must use the attribute of the event object. To obtain an element reference, you can use the legacy DOM or the W3C standard DOM method. This is a good thing.
In fact, the core of the above problem is systemization and concrete. This is a very important point in the learning process. This has indeed solved a lot of questions for me.
Out of the beginner's predicament, we need systematic knowledge and concrete ideas. Thank you for taking the time to read this article. If you want to discuss more questions, please add my QQ: 303551651.