Skip to content

Instantly share code, notes, and snippets.

@ericsoco
Created October 1, 2014 17:29
Show Gist options
  • Save ericsoco/0f95c01bdb5c87fad287 to your computer and use it in GitHub Desktop.
Save ericsoco/0f95c01bdb5c87fad287 to your computer and use it in GitHub Desktop.
wtfjs: negative mod, equality
// Check if a thing is rotated 90°.
function isRotatedOffAxis (rotation) {
return rotation % 180 !== 0;
}
// Hm, what about -180?
console.log(-180 % 180); // -0. wtf #a
// So then why is this ok?
isRotated(-180); // false
// Because:
console.log(0 === -0); // true. wtf #b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment