Last active
April 11, 2022 20:30
-
-
Save MarkTiedemann/429666e3c07ad2a7c554c1ec8a2b04ec 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
| // node --disallow-code-generation-from-strings eval.mjs | |
| console.log(eval("1 + 1")); | |
| // => EvalError: Code generation from strings disallowed for this context |
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
| // node --experimental-fetch fetch.mjs | |
| const res = await fetch("https://nodejs.org/dist/index.json"); | |
| const json = await res.json(); | |
| console.log(json[0].version); | |
| // => v17.9.0 |
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
| // node --frozen-intrinsics primordials.mjs | |
| Array.prototype.push = () => {}; | |
| // With --frozen-intrinsics: | |
| // => TypeError: Cannot assign to read only property 'push' | |
| const a = []; | |
| a.push(1); | |
| console.log(a); | |
| // Without --frozen-intrinsics: | |
| // => [] |
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
| // node --disable-proto=throw proto.mjs | |
| ({}).__proto__.isAdmin = true; | |
| // With --disable-proto: | |
| // => Error: Accessing Object.prototype.__proto__ has been disallowed with --disable-proto=throw | |
| const user = {}; | |
| console.log(user.isAdmin); | |
| // Without --disable-proto: | |
| // => true |
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
| // node --experimental-network-imports --experimental-global-webcrypto uuid.mjs | |
| import validateUUID from "https://unpkg.com/[email protected]/dist/esm-node/validate.js"; | |
| const uuid = crypto.randomUUID(); | |
| console.log(validateUUID(uuid)); // => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment