function iter(array){
  var nextId= 0;
  return {
    next: function() {
      if(nextId < array.length) {
        return {value: array[nextId++], done: false};
      } else {
        return {done: true};
      }
    }
  }
}
var it = iter(['Witajcie', 'Iteratory']);
console.log(it.next().value);
console.log(it.next().value);
console.log(it.next().done);

---

let iter = {
  0: 'Witaj, ',
  1: 'świecie ',
  2: 'iteratorów',
  length: 3,
  [Symbol.iterator]() {
    let index = 0;
    return {
      next: () => {
        let value = this[index];
        let done = index >= this.length;
        index++;
        return { value, done };
      }
    };
  }
};
for (let i of iter) {
  console.log(i);
}

---

function* generatorFunc() {
  console.log('1'); 
  yield;            
  console.log('2'); 
}
const generatorObj = generatorFunc();
console.log(generatorObj.next());

---

function* logger() {
  console.log('start')
  console.log(yield)
  console.log(yield)
  console.log(yield)
  return('end')
}

var genObj = logger();

// Pierwsze wywołanie next wykonuje funkcję od początku do pierwszej instrukcji yield
console.log(genObj.next())

---

function* logger() {
  yield 'a'
  yield 'b'
}
for (const i of logger()) {
  console.log(i)
}

---

const obj = {}
const m2 = new Map([
  [ 1, 'jeden' ],
  [ "dwa", 'dwa' ],
  [ obj, 'trzy' ],
]);
console.log(m2.has(obj));
---

const m = new Map([
  [ 1, 'jeden' ],
  [ 2, 'dwa' ],
  [ 3, 'trzy' ],
]);
for (const k of m.keys()){
  console.log(k);
}

---


