-
ArrayBinding
restElement
must be BindingIdentifier ornull
except when ArrayBinding is part of an AssignmentPattern
-
BindingIdentifier
name
must match the ES6 IdentifierName lexical grammar except whenname
is"*default*"
and BindingIdentifier is thename
of a ClassDeclaration or FunctionDeclaration which is thebody
of an ExportDefaultname
must not be a reserved wordname
must not be a future reserved word in strict mode
-
(12.1.1 and 12.14.5.1 and 14.1.2 and 14.4.1)
name
must not be a restricted word in strict mode
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 () { | |
var g, h; | |
function x() { f = ""; /* var-scoped f gets value "" */ } | |
function y() { g = f; /* g gets value of var-scoped f */ } | |
{ | |
/* var-scoped f is undefined, let-scoped f is a function */ | |
h = f; /* h gets value of let-scoped f, a function */ | |
f = 1; /* let-scoped f gets value 1 */ | |
x(); | |
y(); |
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
var ClassName = (function() { | |
var PRIVATE = {}; | |
function ClassName(state) { | |
this.state = state; | |
} | |
ClassName.prototype.publicMethod = function publicMethod() { | |
this.privateMethod(PRIVATE, "..."); | |
}; |
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
var apply = Function.prototype.call.bind(Function.prototype.apply); | |
function createFunctionES5(name, arity, behaviour) { | |
var params = Array.apply(null, Array(arity)).map(function (x, p) { return "p" + p; }).join(","); | |
var code = "return function " + name + "(" + params + ") { return apply(f, this, arguments); }"; | |
return Function("apply", "f", code)(apply, behaviour); | |
} | |
var define = Object.defineProperty.bind(Object); |
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 escapeUsing(escaper) { | |
return function(literalParts, ...interpolatedParts) { | |
let s = literalParts[0]; | |
for (let [interpolatedPart, literalPart] of zip(interpolatedParts, literalParts.slice(1))) { | |
s += escaper(interpolatedPart) + literalPart; | |
} | |
return s; | |
} | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Countdown Timer</title> | |
<style> | |
body, html { | |
display: flex; | |
align-items: center; | |
justify-content: center; |
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
{-# LANGUAGE PolyKinds, KindSignatures, MultiParamTypeClasses #-} | |
module Main where | |
class Category (arr :: k -> k -> *) where | |
id :: arr t t | |
(.) :: arr b c -> arr a b -> arr a c | |
instance Category (->) where | |
id x = x |
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
module Main where | |
--data Language = English | Spanish | |
--data Censored = Censored | NotCensored | |
--data Encoding = Plain | EncodingA | EncodingB | |
data English | |
data Spanish | |
data Censored |
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
var set = new Set([0, 1]), | |
f = function(x) { return 1 / x; }, | |
g = function(x) { return x ? -0 : x; }; | |
set.map(g); // Set{0} | |
set.map(g).map(f); // Set{1/0} | |
set.map(function(x){ return f(g(x)); }); // Set{1/0, -1/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
function Container(val) { | |
this.val = val | |
} | |
// Functor's `fmap` in Haskell | |
Container.prototype.map = function(f) { | |
return new Container(f(this.val)); | |
}; | |
// Monad's `>>=` (pronounced bind) in Haskell |