What will the function look like, which is a complete analogue of the slice method? What parameters should she have?

Closed due to the fact that the essence of the issue is not clear to the participants Vlad from Moscow , Alexey Shimansky , aleksandr barakin , user207618, Grundy Nov 26 '16 at 21:14 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    Same options as slice . + incoming array (since this is a function). Logically the same - Alexey Shimansky
  • plus the array itself - ra.chobanyan Nov.
  • @ ra.chobanyan The question is meaningless, since the full analogue of slice will look like slice. Next time try to ask something, how to say softer, so as not to offend you, more thoughtfully. - Vlad from Moscow Nov.
  • Well, splice does almost the same - Yuri

1 answer 1

The answer may be:

 let slice = Array.prototype.slice; Array.prototype.mySliceImplement = function(...args){ return slice.apply(this, args); }; let arr = [1,2,3,4,5,6]; console.info(arr.slice(2, 4)); // Original console.info(arr.mySliceImplement(2, 4)); // My function 

  • What is the meaning of the removal of slice into a variable? then this.slice(...args) to do - Grundy
  • one
    @Grundy, it was a subtle hint of irony, which this comment loses sharpness :) - user207618
  • It was too thin :-) next time do not forget the sign - Grundy
  • @Grundy, English level :) What sign? - user207618
  • Sarcasm, Irony, etc. :) - Grundy