Created
October 11, 2017 08:26
-
-
Save js2me/6390dfafe537f848c61f7945b8280435 to your computer and use it in GitHub Desktop.
Basic JavaScript classes extension
This file contains hidden or 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
if (!Array.prototype.last){ //last element of Array :) If you like to write better .last() then [array.length-1] | |
Array.prototype.last = function(){ | |
return this[this.length - 1]; | |
}; | |
}; | |
if (!Array.prototype.first){ //similarly, but first element of array [0] | |
Array.prototype.first = function(){ | |
return this[0]; | |
}; | |
}; | |
if (!Number.prototype.isOne){ // | |
Array.prototype.isOne = function(){ | |
return this == 1; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment