One of my friend use [].slice.call()friends uses [].slice.call() to fill an array with match elementmatched elements.
I wonder how itsthis works. I just know the .push methodArray.prototype.push to fill an array.
Also I have seen there is a difference in both techniquetechniques to fill an array.
So my question is how .slice help to fill an array and what is its role and .push method make and object and .slice make direct array. questions are:
- How does
Array.prototype.slicehelp to fill an array? - What are the roles of
Array.prototype.sliceandArray.prototype.pushto make objects and arrays?
var arr=[];
var arr=[].slice.call($('[id^=name]'));
//arr.push($('[id^=name]'))
console.log(arr)