Home > Web Front-end > JS Tutorial > Take you out of the difficulties of learning javascript

Take you out of the difficulties of learning javascript

黄舟
Release: 2016-12-15 10:37:00
Original
1302 people have browsed it

There will be difficulties in learning any knowledge. Of course, learning JavaScript is the same. This article summarizes some of the difficulties in learning Javascript and explains each difficulty:

 First, use systematic knowledge to make the problem concrete

We often do this when learning Discover that the same problem can be solved in different ways. For example, to bind a click event to an element, you can use on the HTML element. We will initially think that this is the method of binding the event.

When we see for the second time that we can pass a function to an event to bind: a.onclick=f1; then we will think that there is more than one way to bind an event.

When we see the addachEvent("onclick",f1) method used to bind events for the third time, you will definitely think that there may be more than three ways to bind events. And there is no reason to use three identical methods to do one thing. There must be some differences between them?

 So what are the differences between them? How many ways are there to bind events? When you find that a method is incompatible in IE, you still ask why? Is my grammar wrong? Or what happened. After answering questions one after another, you have to ask yourself: "Oh my god! When will I learn JavaScript well?!".

 Maybe it will be difficult for you to learn JS well if this continues. In fact, I want to tell you that you are not far away from learning from him, but you just don’t know how. What's the reason? The reason is that there is no systematic knowledge. The reason is that I have not read the "JavaScript Definitive Guide". He will tell you that there are four methods for binding events, and two of them are basic methods. All browsers support them, and there are two more. Advanced methods, one is the W3C standard method, and the other is the IE standard method, so you know why IE is not compatible with one of the advanced methods, right?

Now that things are concrete, you only need to consider these four methods when binding an event, and you will no longer have so many doubts. You will also feel that you understand the event, and you should next understand other issues. You will also feel that you have finally made progress in JS. Of course, you will also feel that you have come out of a dilemma.

  2. You must understand the history of JavaScript

  Do you understand the history of JS? Of course I understand that it was not originally called JavaScript, and it was not first implemented in IE. Yes, it’s very well said, but it’s not the most important thing. Knowing this will not make you a master. You must understand it in more detail, and mainly understand the history of functional evolution.

Like the above, why are there so many methods for binding events? Why are there so many ways to get an element? Is document.links[] more formal? Or is getElementsByTagName('a') more formal? Which one has better compatibility? How many such methods are there?

 You must know that one question is enough to give you a headache, ten questions will make you unable to start, and a hundred questions will make you doubt yourself. A thousand questions finally come back to the question "Oh my God! When can I learn JavaScript well?" Haha, that's often the case. The solution is to concretize it and understand how many methods there are and why there are these methods. There must be answers to these questions, because JS is not something left by aliens, it was created by humans, and that person's thinking is also limited, right?

 When you know that document.links[] is a legacy document method, and there are a total of 5 such legacy methods. Some problems disappear when they are anchors[], applets[], forms[], images[], links[]. When you also know that the DOM standard retains them, and you also know that all browsers support them, you Also knowing that they are the so-called "Level 0 DOM" you will get out of another "dilemma".

  3. JS has a crisscrossed knowledge structure

  The knowledge structure of JS is crisscrossed horizontally and vertically, which makes it more difficult to understand it. You must have a clear understanding of this. Let’s explain “crisscrossing” below.

 General knowledge has a horizontal nature. For example, from a large perspective, JS is divided into core part and client part. This is horizontal. The core part is divided into lexical structures, data types and values, variables, expressions and operators, statements, objects and arrays, functions, classes, modules and namespaces, and regular expressions. This is also horizontal.

 The client part can be divided into BOM, DOM, events, styles, forms, etc. These are also horizontal knowledge structures.

  A technology rarely uses time as a structure, but because the development of browsers is dynamic, browsers in different periods have different degrees of implementation of JS, and web pages written for the browsers at that time at different times cannot be changed because of technology The development of JS should not be considered, and it is impossible for all websites to be rewritten with the development of technology. Therefore, JS must be developed and upgraded while retaining forward support. Therefore, even if there is a better method, the previous method must be retained. There are many legacy JS properties and methods. For example, the "Level 0 DOM" has been retained in the new W3CDOM. To a certain extent, it is vertical of.

When I have a clear understanding of the knowledge structure, one advantage is that when I want to solve a problem, I can know which piece of knowledge I want to use. For example, if you want to get the position of an element in the document, you will know to use the attributes of the element in the DOM. If you want to get the position of the mouse pointer, you will use the attributes of the event object. To obtain a reference to an element, you can use the legacy DOM or the W3C standard DOM method. This is a good thing.

In fact, the core of the above question is systematization and concreteness. This is a point that I think is very important in the learning process. This really solved a lot of doubts for me.

Any knowledge and technology is the same. As long as you have studied the whole system systematically, the problems you encounter will be slowly solved and you will understand more deeply.

The above is the content that will take you out of the difficult points of learning javascript, and more For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template