Home  >  Article  >  Web Front-end  >  Is typescript compatible with es6?

Is typescript compatible with es6?

青灯夜游
青灯夜游Original
2022-10-20 14:49:231816browse

Typescript is compatible with es6. TypeScript supports ES6 (modules, destructuring, spread, for..of, symbols, computed properties, let/const) starting from 1.5; TypeScript supports modules and the latest modules syntax of ES6, and also supports the Decorator feature of ES7.

Is typescript compatible with es6?

The operating environment of this tutorial: Windows 7 system, ECMAScript version 6, Dell G3 computer.

TypeScript 1.5 is officially released to support ES6

TypeScript 1.5 is officially released, this version is Visual Studio 2015 Part of the update can be downloaded from download for Visual Studio 2013, npm or GitHub Get the latest version.

Notable improvements

ES6 support (modules, destructuring, spread, for..of, symbols, computed properties, let/const, andtagged string templates)

Is typescript compatible with es6?

In addition, TypeScript 1.5 supports the latest modules syntax of modules and ES6; simplifies modules; supports new module output; the compiler supports 'tsconfig.json'; Support the Decorator feature of ES7; better use AngularJS. Please see Release Notes for detailed improvements.

TypeScript is a new language launched by Microsoft, based on JavaScript, which is ultimately compiled and generated by tools. TypeScript is compatible with JavaScript and can load JavaScript code and then run it. The improvements of TypeScript compared with JavaScript include: adding comments to let the compiler understand the supported objects and functions, and the compiler will remove the comments without increasing overhead; adding a complete class structure, making it a completely new aspect object language.

The connections and differences between JavaScript, TypeScript and ES6

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) and has been officially released in June 2015. 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, and its usage is similar to that of var, but let adds a new block-level scope to JavaScript. 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;
  • You can set default function parameters in ES6, such as function A (x, y=9) {};

The relationship between ECMAScript and JavaScript

Due to copyright issues with Netscae, the creator of JavaScript, 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.

The relationship between JavaScript and TypeScript

TypeScript is a superset of Javascript that implements the use of Javascript in an object-oriented programming manner. Of course, the final code is still compiled into Javascript.

The relationship between TypeScript and ES6

typescript Compared with ES6, the biggest improvement of TypeScript is the addition of the type system.

Attachment: Typescript has five major improvements compared to ES5:

  • Type
  • Class
  • Annotation
  • Module import
  • Language toolkit (e.g., structs)

TypeScript is a superset of ES6. Whether you need to use it or not depends on the scenario you need. For example, in Angular2, using TypeScript is obviously better than ES6.

To summarize:

ES6 is the standard for Javascript language, and typescript is a superset of ES6.

【Related recommendations: javascript video tutorial, programming video

The above is the detailed content of Is typescript compatible with es6?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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