Skip to content

Instantly share code, notes, and snippets.

@Semigradsky
Last active June 29, 2016 06:52
Show Gist options
  • Save Semigradsky/ac150f27e68933e3eff442345d92c01f to your computer and use it in GitHub Desktop.
Save Semigradsky/ac150f27e68933e3eff442345d92c01f to your computer and use it in GitHub Desktop.
// Manually simulating an apply() for constructors
var arr = [2011, 11, 24];
new (Function.prototype.bind.apply(
Date, [null].concat(arr)))
// Switching over an object’s constructor
try {
...
} catch (e) {
switch (e.constructor) {
case SyntaxError:
...
break;
case CustomError:
...
break;
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment