How to detect ECMAscript version?

后端 未结 3 1072
感情败类
感情败类 2021-02-19 01:35

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 R

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-19 02:20

    ECMAScript is an industry standard:

    ECMAScript is a trademarked scripting-language specification standardized by Ecma International in ECMA-262 and ISO/IEC 16262. It was created to standardize JavaScript, so as to foster multiple independent implementations.

    Javascript is a popular implementation, more or less:

    JavaScript has remained the best-known implementation of ECMAScript since the standard was first published, with other well-known implementations including JScript and ActionScript. wikipedia

    Considering the current status of JavaScript implementations in various browsers, node.js etc, no one is specifically versioning themselves but keeps evolving with new features. So the best way is to detect, possibly with 3rd party libs, if the feature wanted exists and then use. Otherwise fall back to a more traditional one. Normally it's to try some operations and then check if as expected, no magic.

提交回复
热议问题