Created
December 31, 2015 04:05
-
-
Save bmeck/cc857d0ea1cb56a0ea41 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
| // what does | |
| yield: ({*yield(){yield yield;}}.yield((yield) => yield)); | |
| // mean? | |
| // the key is that in sloppy mode "yield" is not a reserved word | |
| // this is shown in the spec with [~yield] on grammar rules | |
| yield: | |
| // make a labelled statement (the statement that follows gets this label) | |
| // completely useless unless the next statement is an iteration statement (loop) | |
| ( | |
| // start an expression statement | |
| {*yield(){ | |
| // make a concise generator method inside an object literal | |
| // at this point the JS grammar starts to reserve "yield" as an invalid identifier | |
| // seen in the spec as [yield] in grammar rules | |
| yield yield; | |
| // 2 yield operators, 1 with operand, 1 without | |
| // more sane to read as yield(yield); | |
| }} | |
| .yield( | |
| // get the yield property off of the object literal we just made and call it | |
| (yield) => yield | |
| // make an arrow function that returns the first argument passed to it | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment