JSFiddle - React, Tailwind, and code Playground

by Alexander

JavaScript

console.clear();

function Collection(obj) {
  obj[Symbol.iterator] = function*(){
    for (let key in this) yield this[key]
  };
  return obj
}

function makeIterable(obj) {
  obj[Symbol.iterator] = function*(){
    for (let key in this) yield this[key]
  }  
}

Object.prototype[Symbol.iterator] = function*(){
  for (let key in this) yield this[key]
};

/*
const collection = Collection({
  a: 10,
  b: 20,
  c: 30
});
//*/
const collection = {
  a: 10,
  b: 20,
  c: 30
};
//makeIterable(collection);


console.log(collection);

for (let v of collection) {
  console.log(v)
}