Home >Web Front-end >Front-end Q&A >What is the difference between javascript and es6
The difference between javascript and es6: 1. JavaScript is a dynamically typed, weakly typed, prototype-based client-side scripting language, used to add dynamic functions to HTML web pages. es6 is the next generation standard of JavaScript language; 2 , es6 is the language specification of JavaScript, and JavaScript is an implementation of es6.
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
What is JavaScript
JavaScript is a dynamic type, weak type, based on Prototype client-side scripting language, used to add dynamic functions to HTML web pages
Dynamic: determine the data type at runtime. There is no need for a type declaration before a variable is used. Usually the type of the variable is the type of the value to which it is assigned.
Weak class: During calculation, implicit conversion between different types can be transparent to the user. Even if the type is incorrect, the correct type can be obtained through implicit conversion.
Prototype: The new object inherits the object (as a template) and shares its own properties with the new object. The template object is called a prototype. In this way, after the new object is instantiated, it can not only enjoy the properties defined when it is created and run time, but also the properties of the prototype object.
What is ES6
ECMAScript 6.0 (hereinafter referred to as ES6) is the next generation standard of the JavaScript language (now following the ES5 standard), which was officially launched in June 2015 announced. Its goal is to enable the JavaScript language to be used to write complex large-scale applications and become an enterprise-level development language.
New features of ES6
#The let command in ES6 declares variables. The usage is similar to var, but let is new for JavaScript. Block-level scope, there is no block-level scope in ES5, and var has the concept of variable promotion, but in let, the variables used must be declared.
Destructuring assignment of variables in ES6, for example: var [a,b,c] = [0,1,2];
ES6 no longer uses the prototype chain to implement inheritance like ES5, but introduces the concept of Class, which sounds somewhat similar to the syntax of object-oriented programming in Java, but the two are different.
The function definition in ES6 no longer uses the keyword function, but uses => for definition;
In ES6 Default function parameters can be set, such as function A (x, y=9) {};
The relationship between ECMAScript and JavaScript
Because JavaScript Due to copyright issues with the creator Netscae Corporation, ECMAScript cannot be called Javascript. In short, the relationship between ECMAScript and JavaScript is that the former is the specification (language specification) of the latter, and the latter is an implementation of the former.
Extended knowledge
ES6 features are as follows:
1. Block-level scope keyword let, constant const
2. Property value shorthand for object literals
var obj = { // __proto__ __proto__: theProtoObj, // Shorthand for ‘handler: handler’ handler, // Method definitions toString() { // Super calls return "d " + super.toString(); }, // Computed (dynamic) property names [ 'prop_' + (() => 42)() ]: 42 };
3. Assignment deconstruction
let singer = { first: "Bob", last: "Dylan" }; let { first: f, last: l } = singer; // 相当于 f = "Bob", l = "Dylan" let [all, year, month, day] = /^(dddd)-(dd)-(dd)$/.exec("2015-10-25"); let [x, y] = [1, 2, 3]; // x = 1, y = 2
4. Function parameters - default value, parameter packaging, array expansion ( Default, Rest, Spread)
//Default function findArtist(name='lu', age='26') { ... } //Rest function f(x, ...y) { // y is an Array return x * y.length; } f(3, "hello", true) == 6 //Spread function f(x, y, z) { return x + y + z; } // Pass each elem of array as argument f(...[1,2,3]) == 6
[Related recommendations: javascript video tutorial, web front-end]
The above is the detailed content of What is the difference between javascript and es6. For more information, please follow other related articles on the PHP Chinese website!