1

function* generator() {
  yield 'value'
}

console.log(typeof generator()) // object, I double checked :thinking:
console.log(Object.getOwnPropertyNames(generator())) // prints []
console.log(Object.getOwnPropertyNames(Math)) // prints array of methods

Why can't I get same for object returned when calling generator()? It's supposed to have at least a next method.

UPD

Due to a @Barmar 's comment, I see why getOwnPropertyNames is not returning anyhting. Then I am back to the original questiton, how to get all method/properties of the object created by generator function?

knitevision
  • 3,023
  • 6
  • 29
  • 44

0 Answers0