Array.values() does not work

I have been trying to use Array.prototype.values() in my code as specified by MDN documentation and found that it doesn't work in any code playground. The code I've taken directly from the examples on the MDN.

var arr = ['w', 'y', 'k', 'o', 'p'];
var iterator = arr.values();

for (let letter of iterator) {
  console.log(letter);
}

Neither does it work in repl.it, nor in MDN's own sandbox.

I thought that this was due to this function being not supported by Node.js for some reason, but I tried the console in both Chrome and Firefox and got the same error. Am I misunderstanding something? Is it a bug?

Answers:

Answer

By the looks of the browser compatibility table at the bottom of the MDN documentation page, Array.prototype.values() won't be supported until Chrome 66 and Firefox 60 - neither of which have been released yet! Interestingly, it is currently supported by Safari, and have just verified that myself in the developer tools.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.