javascript - What does running slice() on an array do? -


from underscore:

  // create (shallow-cloned) duplicate of object.   _.clone = function(obj) {     if (!_.isobject(obj)) return obj;     return _.isarray(obj) ? obj.slice() : _.extend({}, obj);   }; 

if array detected, dev a

obj.slice() 

i ran in console:

[0,1,2,3].slice() 

and appeared nothing.

what missing?

from mdn:

the slice() method returns shallow copy of portion of array new array object.

when provide no parameters, slice start @ index 0 , go end, giving impression it's doing nothing.

what missing?

parameters.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -