I want to convert an object with indexes as keys, into an array in JavaScript.
For example:
Input: obj ={1: 'banana', 2: 'apple',3:'orange' }
Output: ['orange','apple','banana' ]
I have tried with 'Array.prototype.reverse.apply(obj)', but not able to get the result.
var obj ={1: 'banana', 2: 'apple',3:'orange' };
var res =Array.prototype.reverse.apply(obj);
console.log(res); // return the same object, not reverse
What are the other usages of Array.prototype.reverse()?