Home > Web Front-end > JS Tutorial > Difference Between JavaScript and ECMAScript

Difference Between JavaScript and ECMAScript

php中世界最好的语言
Release: 2017-11-17 10:16:49
Original
1892 people have browsed it

Many people have asked, what is the relationship between JavaScript and ECMAScript? Were there any differences between them before? Today I will give you a detailed explanation of these issues about JavaScript and ECMAScript.

I tried searching on Baidu for "the difference between JavaScript and ECMAScript."

In the end I was completely confused by the massive amount of confusing and conflicting results I got. Desperate:

"ECMAScript is the standard."

"JavaScript is the standard."

"ECMAScript is the specification."

"JavaScript is the ECMAScript standard Implementation. "

##" ECMAScript is standardized JavaScript. "

" ECMAScript is a language. "

#" JavaScript is a branch of ECMAScript.

"ECMAScript is JavaScript."

Hold it, don't cry. I steeled myself and decided to do some painful but fruitful research.

This article represents my current understanding of the differences between JavaScript and ECMAScript. This article is for those who are familiar with JavaScript but want to understand more clearly how it relates to ECMAScript, web browsers, Babel, etc. You'll additionally learn about scripting languages, the JavaScript engine, and the JavaScript runtime.

So, cheer up.

JavaScript/ECMAScript Glossary

The following is a series of definitions, designed with an emphasis on consistency and clarity. The definition is not percent complete. They are designed to illustrate at a high level the connections and relationships between JavaScript and ECMAScript.

Without further ado, let’s get started.

Ecma International

An organization that sets standards for science and technology.

To give a "standard" example (although not invented by Ecma), let's use the keyboard we have used. Does it have most of the letters in the same order, a space bar, an enter key, arrow keys, and the numbers on the top row? This is due to the fact that most keyboard manufacturers base their keyboard designs on the QWERTY layout standard.

ECMA-262 This is a standard published by Ecma International. It contains specifications for a general-purpose scripting language. ECMA-262 is a standard similar to QWERTY, but instead of presenting a keyboard layer specification, it presents a specification for a scripting language called ECMAScript. Think of ECMA-262 as the reference number for ECMAScript.

Scripting Language

A programming language designed specifically for operating on an existing entity or system.

For a general idea of ​​how a programming language might become a scripting language, consider the commands "walk", "run" and "jump". These actions require something to drive them, maybe a person, a dog, or a video game character. "walk", "run" and "jump" are meaningless without an operator to execute these commands. This set of operations is similar to scripting languages ​​that focus on manipulating external entities.

ECMAScript

The specification defined in ECMA-262 is a standard for creating general-purpose scripting languages.

Synonyms: ECMAScript specification

However, ECMA-262 is the name of the standard, which represents the scripting language specification ECMAScript.

ECMAScript provides rules, details, and guidelines that scripting languages ​​must adhere to in order to be considered ECMAScript-compliant.

JavaScript

A general-purpose scripting language that follows the ECMAScript specification.

It is a branched version of the ECMAScript language.

JavaScript is the coffee-flavored language that I like to program (referring to the Java family, translator's note). ECMAScript is the specification on which it is based. By reading the ECMAScript specification, you'll learn how to create a scripting language. By reading the JavaScript documentation, you'll learn how to use the scripting language.

When people call JavaScript a "dialect of the ECMAScript language," they mean the same thing as when they talk about English, French, or a Chinese dialect. A dialect derives most of its vocabulary and grammar from its native language, but deviates enough to be worth retaining these differences.

JavaScript implements most of the ECMAScript specification described in ECMA-262, with a few differences. Mozilla outlines JavaScript's non-ECMAScript language features here:

JavaScript Engine A program or interpreter that can understand and execute JavaScript code.

Synonyms: JavaScript interpreter, JavaScript implementation

JavaScript engines are commonly found in web browsers, including V8 in Chrome, SpiderMonkey in Firefox, and Chakra in Edge. Each engine is like a language module for its application, allowing it to support a certain fork of the JavaScript language.

The JavaScript engine is to the browser what humans understand language. If we take the example of "walking", "running", and "jumping" in our daily behaviors again, a JavaScript engine is the fundamental mechanism that can truly understand the meaning of these actions.

This metaphor can help us explain something about browsers:

Differences in browser performance

Two people may recognize the "jump" command, but one person may respond to the command faster than the other person because he understands and processes the command faster than the other. Similarly, both browsers understand JavaScript code, but one runs faster because its JavaScript engine is implemented more efficiently.

Differences in browser support As another example, there are differences even between people who speak the same language. Even though many people speak English, some may know certain words, expressions, and grammatical rules that others do not, and vice versa. The same goes for browsers. Although all browser JavaScript engines understand JavaScript, some browsers understand JavaScript better than others. This difference exists in browser support for JavaScript.

As for browser support, people usually talk about "ECMAScript compatibility" rather than "JavaScript compatibility", even though the JavaScript engine parses and executes JavaScript. This question is a bit convoluted, and the following table can explain it.

If you remember, ECMAScript is a specification that dictates what a scripting language can look like. Releasing a new ECMAScript version does not mean that all existing JavaScript engines suddenly have these new features. It depends on whether the group or organization responsible for that JavaScript engine wants to update to the latest ECMAScript specification and adopt the changes it brings.


Therefore, developers tend to ask questions like, "Which version of ECMAScript does this browser support?" or "What ECMAScript features does this browser support?" They want to know whether Google, Mozilla and Microsoft have started to update their browsers' JavaScript engines, such as V8, SpiderMonkey and Chakra, to have the latest ECMAScript functionality.


#The ECMASCript compatibility list is a great reference for answers to questions like these.

If a new version of ECMAScript is released, the JavaScript engine will not integrate all the updates at once. They will gradually add ECMAScript functionality, which is evident from Firefox's JavaScript change record:

JavaScript Runtime

The environment in which JavaScript code runs and is interpreted by the JavaScript engine. The runtime provides host objects that JavaScript can run and manipulate.

Synonyms: Host environment JavaScript runtime is the "existing entity or system" mentioned in the scripting language definition. The code is passed through the JavaScript engine, and once parsed and understood, the entity or system will perform the interpreted behavior. A dog walks, a person runs, a video game mission jumps (or causes destruction as in the example above). An application makes itself available to JavaScript scripts by providing a "host object" at runtime. For the client, the JavaScript runtime can be a web browser, in which case host objects such as windows or HTML documents can be used for manipulation. Have you ever used a window or document hosting object? View and document objects are not really part of the core JavaScript language. They are Web APIs, objects provided by the browser that act as a JavaScript hosting environment. For the server side, the JavaScript runtime is Node.js. Server-related hosting objects such as file system, processing, and requests are provided in Node.js. An interesting point is that different JavaScript runtimes can share the same JavaScript engine. V8, for example, is the JavaScript engine used by both Google Chrome and Node.js—two completely different environments.

ECMAScript 6

It is the sixth version of the ECMA-262 standard and features significant changes and improvements to the ECMAScript specification.

Synonyms: ES6, ES2015 and ECMAScript 2015

This version of ECMAScript changed its name from ES6 to ES2015. This is due to Ecma International's decision to release ECMAScript once a year. Accordingly, Ecma International has also begun naming new versions of the ECMAScript specification based on those released each year. In short, ES6 and ES2015 are two different names for the same thing.

Babel

A translator that can convert ES6 code into ES5 code.

Developers can take advantage of the flashy new features in ES6, but worry about cross-browser compatibility for their web applications. At the time of writing this article, Edge and Internet Explorer do not fully support the features in the ES6 specification.

Concerned developers can use Bable to convert ES6 code into a version with the same functionality, but using ES5 features. All major browsers fully support ES5, so they can run your code without worrying about any issues.

An interesting anecdote

I hope this information about JavaScript and ECMAScript is useful to you. Before we wrap up, I want to share a little more information that will enlighten a newbie web developer like me.

Which came first, the chicken or the egg

There is a confusing history about JavaScript because it was developed in 1996. It was then submitted to ECMA International for standardization work in 1997, which led to the birth of ECMAScript. At the same time, since JavaScript is consistent with the ECMAScript specification, it can be said that JavaScript is an example implemented according to ECMAScript.

What is interesting to us is that ECMAScript is based on JavaScript, and JavaScript is based on ECMAScript.

Okay, I know this sounds like a person traveling through time and becoming his or her parents - a bit contradictory, but still pretty funny when I think about it.

Conclusion

I know reading this article has brought you a lot of joy, but the amount of information is still very rich. I have to say goodbye again.

If you have any questions, comments, suggestions or considerations, please let us know.

Thank you very much for reading this article!

Related recommendations:

JavaScript simple return to the top code and comment description

Example of JavaScript implementation of drop-down menu

ECMAScript basic knowledge_javascript skills

The above is the detailed content of Difference Between JavaScript and ECMAScript. For more information, please follow other related articles on the PHP Chinese website!

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