Home>Article>Web Front-end> What is the difference between typescript and es6?
Difference: 1. TypeScript supports all primitive data types, while ES6 does not support all data types; 2. TypeScript has 3 scopes, while ES6 has 2 scopes; 3. Modules in TypeScript are divided into internal Modules and external modules, and modules in ES6 are divided into imported modules and exported modules.
The operating environment of this tutorial: Windows 7 system, ECMAScript version 6, Dell G3 computer.
TypeScript is a free and open source programming language developed by Microsoft. It is a superset of JavaScript and essentially adds optional static typing and class-based object-oriented programming to the language.
TypeScript extends the syntax of JavaScript, so any existing JavaScript program can work under TypeScript unchanged. TypeScript is designed for large-scale application development, and it generates JavaScript when compiled to ensure compatibility.
TypeScript supports header files that add type information to existing JavaScript libraries, extending its benefits to popular libraries such as jQuery, MongoDB, Node.js, and D3.js.
History of TypeScript
Anders Hejlsberg developed TypeScript. It was first launched to the public on October 1, 2012. After two years of development within Microsoft, a new version of TypeScript 0.9 was released in 2013. TypeScript 3.4.5 was released on April 24, 2019.
ECMAScript (ES) is a scripting language specification standardized internationally by ECMA. It was created to standardize JavaScript. The ES scripting language contains many implementations, the most popular of which is JavaScript. Developers primarily use ECMAScript for client-side scripting on the World Wide Web (WWW).
The sixth edition of the ECMAScript standard is ECMAScript6 or ES6, which was later renamed ECMAScript 2015. It is a major enhancement to the JavaScript language that allows us to write programs for complex applications. It adds many features designed to simplify large-scale software development. The most common ES6 web browsers are Chrome and Firefox. The transpiler converts ES6-based code to ES5 which supports many browsers. TypeScript is a transpiler. Grunt, Gulp, and Babel are some other transpilers for compiling modules. Therefore, TypeScript supports ES6.
History
JavaScript was introduced in May 1995 by Brendan Eich. It was originally called Mocha, chosen by Netscape founder Marc Andreessen, and later renamed LiveScript. Meanwhile, Sun Microsystems owns the JavaScript trademark. In December 1995, Netscape obtained a trademark license and renamed it JavaScript.
Between 1996 and 1997, Netscape brought JavaScript to the ECMA standards organization to maintain the specification of the language. In June 1997, ECMA Technical Committee 39 (TC39) was created to continue developing the language, culminating in the publication of ECMA-262 Ed.1.
The first standard version of JavaScript was ECMAScript 1, released in June 1997. A year later, ECMAScript 2 was released, containing only minor changes to keep JavaScript a parallel ISO standard. In December 1999, ECMAScript 3 was released, introducing many popular features of JavaScript. In December 2009, ECMAScript or ES6 was released and subsequently renamed ECMAScript 2015.
1. Primitive data types
TypeScript supports all primitive data types, while ES6 does not support all data types.
2. Variable scope
TypeScript has three scopes: global scope, class scope, and local scope.
ES6 has two scopes: global scope and local scope.
3. Module
In TypeScript, there are two types of modules: internal and external modules
In ES6, modules are divided into import modules and export modules.
【Related recommendations:javascript video tutorial,web front-end】
The above is the detailed content of What is the difference between typescript and es6?. For more information, please follow other related articles on the PHP Chinese website!