📜  ES5 和 ES6 的区别

📅  最后修改于: 2021-09-12 10:39:48             🧑  作者: Mango

1. ECMAScript 5 (ES5P):
ES5 也被称为 ECMAScript 2009,因为它于 2009 年发布。它是一个函数承包商,专注于如何实例化对象。对于 ES5,你必须编写函数关键字和 return,用于定义函数,就像普通的通用 JavaScript 语言一样。

2. ECMAScript 6 (ES6):
ES6 也被称为 ECMAScript 2015,因为它于 2015 年发布。它的类允许开发人员使用 new运算符实例化一个对象,使用箭头函数,以防它不需要使用函数关键字来定义函数,也可以避免使用 return 关键字来获取计算机值。

ES5 和 ES6 的区别:

SR.NO. ES5 ES6
1. ECMA script is a trademarked scripting language specification defined by Ecma international. The fifth edition of the  same is known as ES5 ECMA script is a trademarked scripting language specification defined by Ecma international. The sixth edition of the same is known as ES6 
2. It was introduced in 2009. It was introduced in 2015.
3. It supports primitive data types that are string, number, boolean, null, and undefined.  In ES6, there are some additions to JavaScript data types. It introduced a new primitive data type ‘symbol’ for supporting unique values.
4. There are only one way to define the variables by using the var keyword. There are two new ways to define variables that are let and const.
5. It has a lower performance as compared to ES6. It has a higher performance than ES5.
6. Object manipulation is time-consuming in ES5. Object manipulation is less time-consuming in ES6.
7. In ES5, both function and return keywords are used to define a function. An arrow function is a new feature introduced in ES6 by which we don’t require the function keyword to define the function.
8. It provides a larger range of community supports than that of ES6 It provides a less range of community supports than that of ES5