JavaScript course and experience sharing _ basic knowledge-js tutorial

Source: Internet
Author: User
In the past, JavaScript was only used for some simple web page effects, such as form verification and floating advertisements. At that time, JavaScript was not taken seriously. I. Preface

In the past, JavaScript was only used for some simple web page effects, such as form verification and floating advertisements. At that time, JavaScript was not taken seriously. Since the beginning of AJAX popularity, people have found that using JavaScript can bring a better user experience, and even use this advantage to develop large-scale Web games, so this small language has been paid attention. Nowadays, many companies will recruit specialized JavaScript engineers. JavaScript is usually a necessary skill for WEB Front-end development. A Brief Introduction to the benefits of JavaScriptr does not mean that everyone will learn or even learn it well. Interest is critical. I think interest is the best teacher, it is the motivation for you to focus on one thing and do it well. In addition, you need to believe that small languages have a major role. I used Greasemonkey to write some very useful tools. For example, you can use JavaScript + Greasemonkey to write plug-ins for online web games. Let's talk about my experience and experience in learning JavaScript.

Ii. Getting Started

1. Learn about DIV + CSS layout

Using DIV + CSS to deploy standard web pages can reduce front-end XHTML code and make the structure clearer. This makes it easy to use JavaScript to operate the DOM. For example, to display a list of three rows and three columns, if you want to use the traditional table layout and JavaScript to dynamically generate this list, you need a nested loop. If you use the li structure and CSS floating layout, a loop is enough. Of course, WEB standardization does not necessarily mean that tables cannot be used. I mean, XHTML with clear structures makes JavaScript effects or functions easier to integrate into projects.

2. Master several development and testing tools

As a developer, it is necessary to familiarize yourself with testing tools, which helps you to discover and solve problems more efficiently, especially for large projects. I would like to recommend two of the most commonly used JavaScript and XHTML development and testing tools: Web Developer and Firebug.

3. Familiar with the functions of every JavaScript Method

This requirement seems a little impractical. I think this requirement is true for large languages like C # and JAVA, because these language libraries are too large, I believe no one can fully remember it, and there is no need to remember it all. For example, using JAVA for Web pages is different from the class libraries that mobile development focuses on. JavaScript is not. It does not have many built-in method functions. First, you should be familiar with it and develop it easily. For example, you may think that JavaScript has trim () many languages use the method of removing spaces at the beginning of the line. When you understand the JavaScript built-in function library, you will find that these methods are implemented by yourself in JavaScript. For example, if you transfer JavaScript from other powerful languages, you may think that JavaScript should have an MD5 encryption method. Of course, this is none, but some people use JavaScript to implement this method, that is, JavaScript MD5. In the end, there are few built-in JavaScript methods, but many cool people have written some new methods to add JavaScript Functions. For example, the prototype framework mainly refers to prototype extension of basic JavaScript Functions.

4. Understand DOM Programming

Understanding DOM programming is an important course for learning JavaScript, because in addition to writing some pure data processing logic, JavaScript dynamically changes the structure and content of XHTML, in order to achieve the purpose of dynamic interface updates, and these work must rely on DOM programming. The jQuery framework is well encapsulated in this regard and provides a wide range of DOM operation methods, allowing you to easily find a DOM node (XHTML tag) anywhere on the page ), then perform related operations (add, delete, modify, and query ). I believe this is a quick start for anyone who has experience operating XML documents in other languages.

5. Access and Use AJAX

Today, I learned JavaScript instead of using AJAX, which is an advantage of embedding JavaScript (AJAX itself is not JavaScript content ). AJAX is good for users and servers. It provides a better user experience for users. The most typical application scenario is pre-check of user name availability on the registration page, traditional users may encounter this problem: a user fills in a pile of data and submits a form. The server informs the user that the user has been registered and asks the user to re-enter the data for registration, this is fatal for large multi-user websites, because half of users may have been used to lose 10 user names. For servers, web page traffic is reduced because after AJAX, data is usually loaded on demand and the whole page is not reloaded due to partial updates. For example, if a webpage occupies three screens, we can load only the content of the first screen by default. When the user pulls the scroll bar down, the content of the two or three screens will be loaded. In addition, online WEB map applications are also a model for AJAX.

Iii. Improvement

1. a deep understanding of the JavaScript this keyword

The role and direction of JavaScript this is very different from that of many real object-oriented development languages. It will change if it does not always point to the current object. If you do not pay attention to this problem, you may encounter errors in the code that seem to be correct or do not execute the code.

2. Learning JavaScript OOP Programming

OOP is a good thing. It makes Programmers think about problems more organized and the Code Organization clearer. JavaScript can also be OOP, but there is also a big difference with some traditional OOP languages, so it also takes some effort to be familiar with JavaScript OOP.

3. Understand closures

JavaScript closures are also a much-talked topic. Closures make JavaScript variable scopes complex, but this feature makes the language more flexible.

4. Standardized Learning Development

I believe you have heard of the team spirit. If you work for a company to develop, you can't do without the team. If you want to have a good cooperation, the code of each member must comply with certain specifications, this is also the basic requirement of every company for programmers. The specification usually refers to variable naming, file organization, and annotation specification. This knowledge is similar to the specification of other languages.

5. Read the book of this algorithm.

I think it is not difficult to learn and use a language. It is difficult to use the basic syntax and statements of language to solve some complicated problems. To solve some complicated problems, some algorithms may be used. Some algorithms may be implemented by a team, such as the specific implementation of Chinese word segmentation in the Chinese Emy of sciences, in addition, games often use automatic path search algorithm. Maybe you think that you cannot encounter such a complicated problem in JavaScript development. In fact, it depends on what project you are working on. If you are developing a large web game, generally, you are faced with more challenging problems. If you have read some algorithm books and learn how to solve some common problems, you will naturally become more powerful in the development process. In addition, familiarity with algorithms will certainly be helpful for your future access to other development languages.

Iv. Habits

1. Take notes on compatibility and BUG issues

It is best to take notes on the compatibility between CSS and JavaScript browsers because these problems, or bugs, are strange. the browser will not prompt you where the error is, and IDE will not prompt you, in particular, CSS compatibility issues will cause you to encounter such problems during the development process to become unsolvable for a long time. Even if you have solved similar problems before, you may encounter them again in the future. As a result, you are not prepared to take notes to strengthen your memory, and you are doomed to suffer again because these compatibility problems are not one or two, temporary memory effect is not obvious. In my experience, many problems occur under IE6. Now, IE6 and Microsoft all want to accelerate its destruction. This is of course good news for front-end development.

2. Read excellent code, such as jQuery

Reading good code is definitely a good way to improve yourself. This not only helps you understand the Organization norms of good code, but also provides some functional implementation ideas. For example, jQuery is a very valuable learning JavaScript framework. Of course, to read such a professional JavaScript framework, you must have a solid foundation of JavaScript. Otherwise, you may encounter too many questions during the process and even have a blow to your confidence.

4. Note

1. Avoid using the JavaScript Framework for Development before getting started with JavaScript.

If you do not have any JavaScript basics, do not directly use the JavaScript framework for development. I think this may mislead your understanding of a language, for example, if you directly use jQuery to write a vertex-connected statement, do you think this is a JavaScript syntax? For example, if prototype is enabled, you should not regard the base class method after framework extension as JavaScript built-in. I think the JavaScript framework is used to improve efficiency. It is definitely not something to learn about when getting started with JavaScript.

2. Many examples found online may not be cross-browser compatible

Many JavaScript effect source code was written by a Web user N years ago and Internet Explorer N years ago, so some front-end users are too lazy to solve the problem of cross-Browser Scripting compatibility, so that the written scripts only apply to Internet Explorer. When you get such a piece of code, do not spam it or complain about it, because the code is not of little value. If you understand the cross-browser JavaScript compatibility problem, I believe that you can easily make the code more compatible with few changes.

5. Reading

JavaScript development specification requirements

Related Article

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.