Created
March 2, 2018 10:21
-
-
Save vldvel/54a532b737e5491e7d77b0ccae988d5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function * generator() { | |
yield 1; | |
} | |
generator.prototype.__proto__; // Generator {constructor: GeneratorFunction, next: ƒ, return: ƒ, throw: ƒ, Symbol(Symbol.toStringTag): "Generator"} | |
// as Generator is not global variable we have to write something like this | |
generator.prototype.__proto__.math = function(e = 0) { | |
return e * Math.PI; | |
} | |
generator.prototype.__proto__; // Generator {math: ƒ, constructor: GeneratorFunction, next: ƒ, return: ƒ, throw: ƒ, …} | |
const gen = generator(); | |
gen.math(1); // 3.141592653589793 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment