Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map: assigning array value in for... of loop not working #4051

Closed
jeff-kilbride opened this issue Nov 27, 2015 · 2 comments
Closed

Map: assigning array value in for... of loop not working #4051

jeff-kilbride opened this issue Nov 27, 2015 · 2 comments
Labels
v8 engine Issues and PRs related to the V8 dependency.

Comments

@jeff-kilbride
Copy link

This example from the MDN site is not working in Node 4.2.2:

var myMap = new Map();
myMap.set(0, "zero");
myMap.set(1, "one");
for (var [key, value] of myMap) {
  console.log(key + " = " + value);
}
// Will show 2 logs; first with "0 = zero" and second with "1 = one"

When I run this, I get:

/home/jeff/foo.js:4
for (var [key, value] of myMap) {
         ^

SyntaxError: Unexpected token [
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:414:25)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:136:18)
    at node.js:963:3

Thanks!

@ilkkao
Copy link

ilkkao commented Nov 27, 2015

That is expected. ES2015 array destructuring is not implemented yet in V8.

@mscdex mscdex added the v8 engine Issues and PRs related to the V8 dependency. label Nov 27, 2015
@cjihrig
Copy link
Contributor

cjihrig commented Nov 27, 2015

Correct. Closing as not a bug.

@cjihrig cjihrig closed this as completed Nov 27, 2015
This was referenced Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

4 participants