In some projects that I work, was added some blocks with this syntax:
var [code, name] = input.split("/");
console.log(code);
console.log(name);
I really like this, is so simple and small. It’s true I can do this using other syntax like:
var code_name = input.split("/");
console.log(code_name[0]);
console.log(code_name[1]);
But, some browsers like Google Chrome and Opera dont support this “feature”. Somebody know if this is a future feature of JS or is deprecated? In case deprecated, exist some beaultiful alternative to the first case?
Thanks for all.
See:
Possible to assign to multiple variables from an array?
for a similar discussion – unfortunately no cross browser solution seems to exist at the moment – safer to use a temp variable