Home >Web Front-end >JS Tutorial >Node.js check for ES6 support

Node.js check for ES6 support

巴扎黑
巴扎黑Original
2017-07-18 16:24:361842browse

ode.js is developing very fast, and its support for es6 features is becoming more and more conscientious. However, there are many versions of node.js, and each version has different support for es6. In order to clearly understand how each version supports es6 features To support, there needs to be a tool that can provide clearer support instructions, and can even provide support for a certain feature by calling it in the program, and help the program selectively use es6 features.

es-checker provides relatively easy-to-use related functions. It can detect the current node and provide feature support instructions. It can also provide methods in the program to detect whether a certain feature is supported.

Installation and detection

The current node version is v6.9.4.

Global installation

npm install es-checker -g

After installation, execute in the command line

es-checker

Execution result

The es feature in the program supports detection

var Supports = require("es-checker"); 
if (Supports.letConst) {
  let x = 5;
} else {  var x = 5;
}

Reference:

es-checker’s github

End

The above is the detailed content of Node.js check for ES6 support. 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