Created
May 18, 2011 23:05
-
-
Save gabehollombe/979788 to your computer and use it in GitHub Desktop.
Adding a custom 'seconds' function on to Number 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.seconds = function(){ return this * 1000 } | |
=> function (){ return this * 1000 } | |
> 1..seconds() | |
=> 1000 | |
> (1).seconds() | |
=> 1000 | |
> 1['seconds']() | |
=> 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pity some "browsers" don't support getters and setters.