+ 1

What is the code do?

I dont know what happen on array when we applied a array to this methods? https://code.sololearn.com/Wjcf5sLFf7Rl/?ref=app https://code.sololearn.com/Wjcf5sLFf7Rl/?ref=app

5th Mar 2020, 9:49 AM
Alireza Babaei
Alireza Babaei - avatar
1 Resposta
+ 4
Before es6 there was no class keyword to write OOP program in j JavaScript. Functions was the only way to write OOP program in JavaScript. Every function is considered is an object in JavaScript and they can have multiple methods which can be accessible through prototype. Array is an object. It has some built in methods which can also be accessible via calling its prototype followed by their method name. Array.prototype.slice.call() Here Array is the JavaScript's built-in object. Prototype is the way accessing it's method. Slice is method and call() is the method which is responsible for calling the method. All this means you are calling the built in Array slice method. Normally, calling var b = a.slice(); will copy the array a into b. However, we can't do var a = arguments.slice(); because arguments isn't a real array, and doesn't have slice as a method. Array.prototype.slice is the slice function for arrays, and call runs the function with this
5th Mar 2020, 9:31 PM
Md. Shahriar Parvez
Md. Shahriar Parvez - avatar