Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Reversing the elements in an array-like object

const obj = {0: 1, 1: 2, 2: 3, length: 3};
console.log(obj); // {0: 1, 1: 2, 2: 3, length: 3}

Array.prototype.reverse.call(obj); //same syntax for using apply()
console.log(obj); // {0: 3, 1: 2, 2: 1, length: 3}
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #Reversing #elements #object
ADD COMMENT
Topic
Name
9+3 =