FK | Cstr | TM: Lexical | TM: Global / Strict |
---|---|---|---|
normal | cstr | - | function() {}; new Function |
normal | no | () => {} | x() {} |
classConstructor | cstr | - | class {} |
classConstructor | no | - | - |
generator | cstr | - | - |
generator | no | - | function * () {}; * x() {} |
async | cstr | - | - |
async | no | async () => {} | async function() {}; async x() {} |
This file contains 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
// This module installs a custom global DOM event, 'urlchange', which is | |
// dispatched when the URL _semantically_ changes for any reason. | |
// | |
// It also alters URL behavior more generally. The URL is kept consistently in a | |
// canonical form, such that differences in the order of query parameters (other | |
// than same-key parameters, whose order is potentially meaningful) are | |
// eliminated. While the event is not fired on load, URL canonicalization may be | |
// performed. | |
// | |
// Like HashChangeEvent, URLChangeEvent has two properties, 'newURL' and |
This file contains 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
void async function() { | |
const asyncGenerator = async function *() { try { yield; } catch {} }(); | |
try { | |
for await (const value of asyncGenerator) { | |
await asyncGenerator.throw(new Error); | |
} | |
console.log('caught'); | |
} catch { |
This file contains 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
import range from '/util/iterator/range.mjs'; | |
// Week start data pulled from similarly golfed answer on SO: | |
// https://stackoverflow.com/a/57102881/1631952 | |
// | |
// I’m not thrilled with this; we probably ought to be generating it since the | |
// data is pretty obscure. OTOH I’d be far less thrilled with loading hefty | |
// chunks of ICU data and this is pretty solid and compact! | |
// | |
// Note that the RegExp given for lang tags in that answer is a bit off. The one |
Trying to understand what accounts for "\8"
and "\9"
being considered valid string literals with identity escapes in Chrome and FF.
Annex B permits sloppy mode to include legacy octal escapes in strings. It achieves this by replacing the ‘normal’ (strict) EscapeSequence production with a new version accompanied by three new productions.
- Strict: https://tc39.es/ecma262/#prod-EscapeSequence
- Sloppy: https://tc39.es/ecma262/#prod-annexB-EscapeSequence
In the sloppy version, three of the alternatives are the same. The change is replacing this rule:
"0" [lookahead ∉ DecimalDigit]
This file contains 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
class Foo extends Bar { | |
method() { | |
const homeObject = Foo.prototype; | |
const superReferenceBase = Object.getPrototypeOf(homeObject); | |
} | |
static method() { | |
const homeObject = Foo; | |
const superReferenceBase = Object.getPrototypeOf(homeObject); | |
} |
This file contains 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 matchAllButUpdateOriginalRegExp(regExp, string) { | |
return regExp[Symbol.matchAll].call({ | |
constructor: { [Symbol.species]: function() { return regExp; } }, | |
flags: regExp.flags, | |
lastIndex: regExp.lastIndex | |
}, string); | |
} | |
const pattern = /./g; |
This file contains 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
export default function acornSkullFishKoalaCaressingAndNonstopSpinalDraining(Parser) { | |
const tt = Parser.acorn.tokTypes; | |
const ocToken = new Parser.acorn.TokenType('?.'); | |
const ncToken = new Parser.acorn.TokenType('??', { | |
beforeExpr: true, | |
binop: 2.5 | |
}); | |
return class extends Parser { | |
getTokenFromCode(codePoint) { |
This file contains 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
// CLASS SYNTAX //////////////////////////////////////////////////////////////// | |
class AFoo {} | |
class ABar extends AFoo {} | |
// FUNCTION SYNTAX NEAR-EQUIV ////////////////////////////////////////////////// | |
function BFoo() { | |
if (!new.target) { | |
throw new TypeError('Illegal constructor'); |
This file contains 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
// This is useful for a few things: | |
// | |
// 1. Checking what dictionary options are supported by some platform API. | |
// 2. Debugging mysterious cases where an object you pass as input to another | |
// API doesn’t seem to get treated the way you’re expecting. | |
// 3. When designing another Proxy’s handler implementation, verifying that you | |
// are accounting for everything correctly and that the intended abstraction | |
// isn’t leaking in quirky ways. | |
// | |
// ex: |