Skip to content

Instantly share code, notes, and snippets.

@gabehollombe
Created May 18, 2011 23:05
Show Gist options
  • Save gabehollombe/979788 to your computer and use it in GitHub Desktop.
Save gabehollombe/979788 to your computer and use it in GitHub Desktop.
Adding a custom 'seconds' function on to Number in JavaScript
> Number.prototype.seconds = function(){ return this * 1000 }
=> function (){ return this * 1000 }
> 1..seconds()
=> 1000
> (1).seconds()
=> 1000
> 1['seconds']()
=> 1000
@gabehollombe
Copy link
Author

gabehollombe commented May 22, 2011 via email

@taybenlor
Copy link

Pity some "browsers" don't support getters and setters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment