Out of JavaScript beginner's Dilemma-js Beginner's Basics

Source: Internet
Author: User

From the beginning of contact with JS this thing has a year, heart is always some can not speak out of the anguish. It is often said in forums. So where is the bitter? Always feel that learning is not in-depth, some simple things can be done but also can not be handy. Could you tell me more about this pain? All said is "cannot say the anguish" how concrete?

What is the unspoken? Cannot say, can not be specific, can not put the problem to implement can not be solved. This is the unspoken! I think this is the beginner's "dilemma". The reason to use "I think" just to cater to the title of this article "experience" two words. I am very happy if I can help you.

Next to the point, I went through the reflection and thought summed up the following several beginners "embarrassing" everyone to see if we have to talk about the hearts of children, hehe.

First, use the knowledge of the system to specify the problem

We often find that we can use different methods to achieve the same problem when we study. For example, to bind a click event to an element, you can use the <a href= "#" onclick= "F1 ()" ></a> on HTML elements, which we initially think is the method of binding events.

When we see the second time we can pass a function to an event to bind: A.ONCLICK=F1; Then we think that the original binding event is not just one method.

When we see the third time to bind an event with addachevent ("onclick", F1), you'll probably want to bind the event in more than three ways. And there is no reason to do one thing three of the same way, there must be a difference between them?

So what's the difference between them? How many ways are there to bind events? When you find that a method is not compatible in IE, you will also ask why this is why? Is my grammar wrong? Or what's going on. After one problem after another, you have to ask yourself: "God!" When can I learn JavaScript well?! “。

Maybe it's hard for you to learn JS well. In fact, to tell you that you are not far from learning him, but you do not know how to go. Where is the reason? The reason is that there is no systematic knowledge, the reason is that you have not read the JavaScript Authority Guide, he will tell you that there are four ways to bind events, and there are two basic methods, all browsers support him, and there are two advanced methods, one is the standard method of the Internet, the other is IE standard method, So you know why IE is not compatible with one of these advanced methods, right?

Now that things are materialized, when you bind an event, just consider these four ways, and you won't have that much doubt. You will also feel that you understand the incident, the next step you should go to understand other issues, you will also feel that you have finally made a progress in JS, of course, you will feel a dilemma.

Second, you must understand the history of JavaScript

Do you know the history of JS? I certainly understand, he was not called JavaScript, he was not implemented in IE in the first. Yes, well said, but this is not the most important, know this will not become a master, you have to understand more detailed, and mainly to understand the history of functional evolution.

Just like the above, why is there so many ways to bind events? Why is there so many ways to get an element? Bottom is document.links[] regular point? Or is getElementsByTagName (' a ') a bit more formal? Which compatibility is better? How many more of these methods are there?

To know a problem is enough headaches, 10 questions you can not start, 100 questions you will doubt yourself. 1000 questions and finally back to the question "Oh my God!" When can I learn JavaScript "? Oh, this is often the case. The solution is to crystallize him, to figure out how there are several ways, and why these methods. These questions must have the answer, because JS is not what the aliens left Behind, is created by people, and that person's thinking is limited, isn't it?

When you know document.links[] is a legacy document method, and there are 5 of these legacy methods. Anchors[],applets[],forms[],images[],links[] Some problems disappear when you know that the DOM standard retains them, and you know that all browsers support them, and you know they're called "Level 0 dom." You're going to get out of a "dilemma" again.

Three, JS has criss-cross knowledge structure

JS knowledge structure is horizontal and vertical staggered, which increases the understanding of his difficulty, this point must have a clear understanding. Let's explain the "criss-cross".

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

The client part can be divided into Bom,dom, events, styles, forms, etc., which are also horizontal knowledge structure.

A technology rarely uses time as a structure, but because the development of browsers is dynamic, browsers in different periods of time to a different degree of JS implementation, and at different times for the browser to write the Web page can not be because of the development of technology not to consider him, and let all the site with the development of technology and rewriting is impossible, So JS is to develop upgrades, but also to retain the support of the forward. So even if there is a better way to retain the previous method, there are a lot of legacy JS properties and methods, such as "Level 0 dom" in the new W3cdom has been retained, in a way he is portrait.

When you have a clear understanding of the structure of knowledge, there is a benefit that when I have to solve a problem, I will be able to know what kind of knowledge I want to use. For example, to get an element's position in the document, you will know that the attributes of the elements in the DOM are used, and that the position of the mouse pointer will be used with the properties of the event object. To get a reference to an element, you can use the DOM method of the standard for the DOM as well as the left. This is a good thing.

In fact, the core of the above problem is systematization and materialization, which I think is very important in the process of learning. This really solves a lot of puzzles for me.

Out of the beginner's dilemma, we need systematic knowledge and concrete thinking. Thank you for taking the time to read this article and hope it will help you. If you want to discuss more questions, please add my qq:303551651.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.