I was trying to slice an object using Array.prototype, but it returns an empty array, is there any method to slice objects besides passing arguments or is just my code that
var obj = {0: 'zero', 1: 'one', 2: 'two', 3: 'three', 4: 'four'}; var result = Object.keys(obj).slice(0,2).map(key => ({[key]:obj[key]})); console.log(result);
[ { '0': 'zero' }, { '1': 'one' } ]