ECMA and Iterators


I’ve been trying to figure out how to create a class using the iterator functionality to step through a class as if it was an array. I put up a stackoverflow question but no answer as of yet. I just get compilation errors, one user suggested it isn’t supported, but it seems from the babel being used it should be???

I’d like to do something like:

fruits=new Fruits('apple','orange','pear');

for(let fruit of fruits) {

Using something like:

Fruits = class Fruits {
   constructor(fruitArray) {
   * [Symbol.iterator]() {
        for (let fruit of this.fruitArray) {
           yield fruit;