Last active
February 3, 2022 19:23
-
-
Save NullDev/2b0c108b252a06033cb7ad4d81a847b3 to your computer and use it in GitHub Desktop.
A weird implementation of PHP's Spaceship operator in JavaScript
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
Number.prototype["<=>"] = function(x){ | |
return Math.sign(this - x); | |
} | |
var result = 5 ["<=>"] `4`; | |
console.log(result); | |
// https://jsfiddle.net/veyar51m/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment