View Single Post
Old 01-06-2013, 12:36 AM   PM User | #22
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
We could use it to create list and dictionary comprehensions . Or our own slice() method:

Code:
function listSlice(element, index, array) {
    if (!this[2]) this[2] = array.length - 1;
    if (index >= this[1] && index <= this[2]) {
        this[0].push(element);
    }
}
var a = [ 2, 5, 9, 8, 6 ], b = [];
a.forEach(listSlice, [b, 2]);


console.log(a); // [ 2, 5, 9, 8, 6 ]
console.log(b); // [ 9, 8, 6 ]
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS

Last edited by AndrewGSW; 01-06-2013 at 12:50 AM..
AndrewGSW is offline   Reply With Quote