Last active
September 4, 2019 14:19
-
-
Save je3f0o/0f53ddb7cd36288fa2d67a1f383f791e to your computer and use it in GitHub Desktop.
I discovered some weird syntaxes while programming ES8 parser.
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
let yield = 3.14; | |
// ^^^^^ | |
// Hey! yield is not reserved keyword? | |
let await = yield; | |
// ^^^^^ ^^^^^ | |
// Okay, even await isn't reserved keyword too? | |
// Let's do something crazy... | |
let {} = {}; // WTF ??? | |
let [] = []; // How is that valid syntax? | |
{ | |
let async_fn = async () => {}; | |
async function await () { | |
// ^^^^^ Async function's name can be await. WTF??? 😲 | |
return await async_fn(); | |
} | |
function * yield () { | |
// ^^^^^ Generator function's name can be yield. Really??? | |
yield yield yield yield yield; // You are kidding me! 😁 | |
} | |
} | |
// Let's do even more crazier... | |
let o = { | |
while () {}, if () {}, function () {}, let () {}, const () {}, | |
3.14 () {}, | |
null () {}, | |
undefined () {}, // Ok, I gave up!!! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment