JavaScript1.7 error in GoogleChrome
Example:
var x, y;
try {
[x, y] = ["1", "2"];
document.write(x+": "+y);
} catch(e){
console.log(e);
}
catch erro:
Invalid left-hand side in assignment JavaScript1.7
I need actually is to test if the browser supports javascript1.7
What I need is to actually test if the browser supports javascript1.7
But without using this kind of code:
jsversion = 1.7;
This code beyond invalid by the w3c, is also working with global variables,
which can be a very bad thing (can cause conflicts and other problems)
I tried using the following code (but error occurs in “strict”)
var i=0;
try{
yield i;
} catch(ee) {
document.write(ee);
}
So this is what I need to do, to test if the browser supports javascript1.7.
Thanks.
Try
This uses
evalto parse a bit of code which uses ES.next pattern decomposition but which is not valid EcmaScript 5. The rest of the code which declares and assignsisESNextis valid EcmaScript 3 code though so should run on all browsers.The problem you’re running into is due to Chapter 16:
But the code snippet above gets around the early error because