问题描述
我想查看我在浏览器中使用的ECMAscript版本(例如chrome 59),因为处理某些RegExp东西时ECMAscript3和ECMAscript5之间存在一些差异.
我已找到有关此信息,但找不到有关如何检测ECMAscript版本的具体答案.
提前致谢.
I want to see what ECMAscript version I'm using in my browser(e.g,chrome 59) ,because there is some difference between ECMAscript3 and ECMAscript5 when dealing with something RegExp stuff.
I've found the relevant information about this,but I can't find a specific answer about how to detect the ECMAscript version.
Thank's in advanced.
推荐答案
也许您可以尝试使用ES6
中专门添加的某些数据结构,例如Map
,Set
等.这是为了区分ES5
和ES6
,但是您可以查找在ES5
中添加的功能,而在您的情况下ES3
中不存在这些功能?
May be you can try to use some data structures that are specifically added in ES6
like Map
, Set
etc. This is to differentiate between ES5
and ES6
but you can look up for features that are added in ES5
which are not present in ES3
in your case?
try {
var k = new Map();
console.log("ES6 supported!!")
} catch(err) {
console.log("ES6 not supported :(")
}
try {
var k = new HashMap();
console.log("ES100 supported!!")
} catch(err) {
console.log("ES100 not supported :(")
}
这篇关于如何检测ECMAscript版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!