📜  ES5与ES6

📅  最后修改于: 2021-01-01 04:20:47             🧑  作者: Mango

ES5和ES6之间的比较

ECMAScript是ECMA International定义的商标脚本语言规范。创建它是为了标准化JavaScript。 ES脚本语言有许多实现,流行的是JavaScript。通常,ECMAScript用于万维网的客户端脚本。

ES5是的ECMAScript 5的缩写,也被称为2009的ECMAScript ECMAScript标准的第六版是ES6ECMAScript的6。它也被称为2015年的ECMAScript 的JavaScript语言,使我们能够编写复杂的应用程序。

尽管ES5和ES6在本质上有一些相似之处,但它们之间也有许多不同之处。

让我们看一下ES5和ES6之间的一些区别。 ES5和ES6之间的比较列表如下:

ES5和ES6之间的区别

Based on ES5 ES6
Definition ES5 is the fifth edition of the ECMAScript (a trademarked scripting language specification defined by ECMA International) ES6 is the sixth edition of the ECMAScript (a trademarked scripting language specification defined by ECMA International).
Release It was introduced in 2009. It was introduced in 2015.
Data-types ES5 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.
Defining Variables In ES5, we could only define the variables by using the var keyword. In ES6, there are two new ways to define variables that are let and const.
Performance As ES5 is prior to ES6, there is a non-presence of some features, so it has a lower performance than ES6. Because of new features and the shorthand storage implementation ES6 has a higher performance than ES5.
Support A wide range of communities supports it. It also has a lot of community support, but it is lesser than ES5.
Object Manipulation ES5 is time-consuming than ES6. Due to destructuring and speed operators, object manipulation can be processed more smoothly in ES6.
Arrow Functions 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.
Loops In ES5, there is a use of for loop to iterate over elements. ES6 introduced the concept of for…of loop to perform an iteration over the values of the iterable objects.

转译

截至目前,尚没有完全支持ES6功能的浏览器。但是,我们可以使用transpilation将ES6代码转换为ES5代码。

有两个主要的编译器BabelTraceur ,用于在构建过程中将ES6代码转换为ES5代码。

点差运算符(…)

它是在ES6中引入的,它使合并数组和对象变得容易。

模板字面量(`)

这是ES6中引入的一项新功能,使我们可以使用字符串。模板字面量使我们能够轻松地执行字符串插值。