I often have typos typing the word "length" and would like to make a short name for this property. For example, "len"
I can easily create an array method:
Array.prototype.len = function(){ return this.length }
but then I have to call [1,2,3] .len () with brackets ...
But how to make real estate? (and name it with [1,2,3] .len)
I tried something like this:
Array.prototype.len = (function(arr) {return arr.length})(this)
but this one is not displayed that way
Thanks in advance
source
share