Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Why is JavaScript so difficult?

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains why JavaScript is so difficult. Friends who are interested might as well take a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn why JavaScript is so difficult.

Implicit transformation of difficulty

Javascript truth table, you can experience it.

This pointing to the problem

This in javascript is not statically bound, but dynamically bound. And the direction can be changed artificially.

Take a look at this example

What will the console output?

Closure

The scope in javascript can be looked up, and the function can refer to the underlying scope variables through closures, and the underlying scope can be accessed at a high level. It doesn't seem to be rare.

Look at the example.

What does this example output?

Domain chain

There is nothing to say about the scope chain, just go to the code

Why the output of undefined, do not understand to find their own reasons.

Prototype chain

Javascript uses a non-mainstream object mechanism, object inheritance mechanism based on prototype chain. This requires us to abandon the idea of Class in many languages. Take a closer look at this prototype chain.

Understand the difference between this.getName,A.prototype.getName and A.getName in the object constructor.

EventLoop

Unlike many other languages, code in javascript is executed sequentially. There is an EventLoop in both browsers and Nodejs. Make the code coding uncontrollable. The difficulty in Nodejs is increased exponentially.

Example:

Think about it, what is the result of the operation?

At this point, I believe you have a deeper understanding of "why JavaScript is so difficult". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 206

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report