Sitelet https://github.com/nodejs/node/issues/4051
Skip to content

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

Description

@jeff-kilbride

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!

Activity

  1. ilkkao commented on Nov 27, 2015

    @ilkkao

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

  2. added
    v8 engineIssues and PRs related to the V8 dependency.
    on Nov 27, 2015
  3. cjihrig commented on Nov 27, 2015

    @cjihrig
    Contributor

    Correct. Closing as not a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions