Skip to content

Instantly share code, notes, and snippets.

@epitron
Last active August 29, 2015 14:10
Show Gist options
  • Save epitron/75810fd0aa8f31f31487 to your computer and use it in GitHub Desktop.
Save epitron/75810fd0aa8f31f31487 to your computer and use it in GitHub Desktop.
wtf
$ Number.prototype.divmod = function (n) { return [Math.floor(this / n), this % n]; }
=> function (n) {
return [Math.floor(this / n), this % n];
}
$ typeof 1
=> "number"
$ typeof 1.0
=> "number"
$ 1.0.divmod
=> embedded:16 function (n) {
return [Math.floor(this / n), this % n];
}
$ 1.divmod
=> VM378:762 Uncaught SyntaxError: Unexpected token ILLEGAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment