JavaScript will become the first language for computer learning

Source: Internet
Author: User

We teach students who have received the center of mathematics and science courses. Therefore, we can do some exercises or projects that will stimulate your interest.

Using JavaScript as the first language is very exciting. It is frustrating to teach prototype inheritance methods to developers who are familiar with traditional inheritance methods (resulting in the emergence of many libraries that inherit classes in JavaScript replication ). It is easier to introduce prototype inheritance to those who have not received any inheritance method learning. The same is true for learning functional programming. Using JavaScript can also experience functional programming, which is also a focus of our courses.

Before using JavaScript as the first language, there are several difficulties to overcome (this is often encountered when JavaScript is used ). To avoid these common problems, we need to use some form of linting (JSLint, JSHint, or something similar) in the code editor to tell the user environment information.

We hope to avoid the traditional grammar teaching method, so that you can easily master it by using this language. There are two major changes to simplify the learning process.

Note: These special recommendations can be truly effective only when the learner is someone who has never been familiar with any programming language, related specifications, code, and libraries. Of course, there is still a lot of work to do if you want to improve the student hierarchy so that they can "see any cross-browser JavaScript code and understand the meaning of the code.

Forced type conversion

As many people have pointed out, forced type conversion is a very confusing thing, which Douglas Crockfor mentioned in JavaScript: The Good Parts.

You can discuss this issue after learning other courses... For example, after learning the prototype, the function program design and closure.

The first change I recommend is to only allow students to use = (and! = ). Although '=' is relatively short in syntax, it has many restrictions and usage of forced type conversion. It doesn't make much sense to teach this content before preliminary learning programming.

One exception is that if you need to check whether a variable is null or an undefined value. This can be taken through a simple someVar = null example, which is the only place where = is used. (The other exception is the browser bug in IE, which always returns false if you use = to check Windows objects, but we will not introduce this example in our courses .)

Falsy Value

Like =, falsy values can lead to confusion. Performing a strict Boolean check reduces the edge effect, but increases the amount of code. You can limit the falsy value to a Boolean value, null and undefined value, and leave the falsy value of the string for future study.

Function Declaration

The most interesting change is a very subtle change, which avoids the function declaration when creating anonymous functions and specifying variables for them.

Using this technique can cultivate some good habits.

It is easier to understand "functions are objects ". I found that when you display a function with specified variables to developers, they are more likely to understand that a function is an object (and a function can be passed to another function as a parameter ). The students can better understand functional programming.

It can form a good usage habit of semicolons. Only in the traditional function declaration do not need to end with a semicolon (of course, including conditional statements and loop statements), so that students are quite clear about how to use a semicolon.

Do not have too many packages related to function functions and loops,

Block Scope

This is the last challenging knowledge point. So far I have not found a particularly good teaching solution. It is already a headache for developers to figure out the variables declared in the loop. If the scope of the variable declaration cannot be explained more intuitively, it can only be explained from a purely technical perspective.

(But I'm not sure if I should introduce function () {…} at the beginning (){...} (); Such a function block .)

Use JavaScript as the first language

It should be noted that although we are preparing to use JavaScript as the first language-mainly because it is universal and meets the needs of a large number of work environments, it does not need to be installed in advance, development content can be shared-but we will not focus on JavaScript alone. There are also a lot of other languages that are also very important. From these languages, we can learn a lot of skills that are not available in JavaScript. We should also add this content to our courses.

Introduced in the video

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.