Created
September 30, 2021 07:20
-
-
Save sagarpanchal/e83afb27c96ff2df9251ee919d5fa76b to your computer and use it in GitHub Desktop.
number.proto.js
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
Object.defineProperty(Number.prototype, 'decimal', { | |
get: function decimal() { | |
Number.precision = 'precision' in Number ? Number.precision : 3; | |
const f = Math.pow(10, Number.precision); | |
return Math.round(this * f) / f; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment