简体   繁体   中英

What determines the available ECMAScript version?

I've been assigned to debug an old Visual Basics website, in which we only have access to the JavaScript.

The issue is that there have been used "With" statements all over the place, some even including "remove()" inside.

This made me wonder, is it the browsers determining the available version of ECMAScript, or is it something else? Because if it's the browser then i guess i can use "let" to solve most of the scoping issues i'm guessing "with" has been used to solve.

Edit: An example of how the with statements are used in the code (context for this can be found in comments):

function firstFunction(input1) {

    var someVariable = document.getElementById('someId');

    var i = someVariable.options.length;

    with (someVariable) {
        options[i] = new Option();
        options[i].text = input1.Name;
        options[i].value = input1.Id + ';' + input1.Type;
        i++;
    }
}

function secondFunction(input2) {

    var someVariable = document.getElementById('someId');

    var i = someVariable.options.length;

    with (someVariable) {
        options[i] = new Option();
        options[i].text = input2.PrettyName;
        options[i].value = input2.Name;
        i++;
    }
}

It's the JavaScript engine used by the browser: V8 in Chrome, Chromium, and Opera; SpiderMonkey in Firefox; JScript in IE8; and Chakra in IE9+ and Edge (the verson of Chakra in IE9+ is very out-of-date; Edge's is quite up-to-date).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM