From a7cf295a6b4abbc25cf46c77999d1d4a83ae7c53 Mon Sep 17 00:00:00 2001 From: Olmo Maldonado Date: Sun, 29 Mar 2009 13:09:49 -0700 Subject: [PATCH] Optimized Array.item: http://gist.github.com/87505 --- Source/Native/Array.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Source/Native/Array.js b/Source/Native/Array.js index e671ca55..5a72da13 100644 --- a/Source/Native/Array.js +++ b/Source/Native/Array.js @@ -77,12 +77,10 @@ Array.implement({ return this; }, - item: function(at){ - if (!this.length) return null; - if (at < 0) at += this.length; - return (at < this.length) ? this[at] : null; + item: function(at, l){ + return (!(l = this.length) || ((at < 0) ? at += l : at) > l) ? null : this[at]; }, - + getLast: function(){ return (this.length) ? this.item(-1) : null; }, -- 2.11.4.GIT