Answers for "Reversing the elements in an array-like object"

0

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}
Posted by: Guest on May-03-2022

Code answers related to "Reversing the elements in an array-like object"

Code answers related to "Javascript"

Browse Popular Code Answers by Language