Experimenting with JavaScript

Hurray! Tuj wrote a line of JavaScript!

Reflect.apply(Array.prototype.slice, "hello world!",[0,4]);

Ack! Tuj got smacked for calling a function in a complicated way. ;_;

Why does one have Math.floor instead of Math.prototype.floor? Because Array is a global Function object whereas Math is a global Object which is not a Function object.

Why not Array.slice, but Array.prototype.slice? Let a be an array. One calls a.slice(0,4) for example. Since the slice function is common to all Array objects, to avoid duplication, it is attached to the Array.prototype object. An array automatically receives the properties from Array.prototype rather than from Array.

Then why does one have Array.from instead of Array.prototype.from? One calls Array.from("cat") for example. After creating an array, Tuj checked that it did not possess the from property.  It looks that from is a property of the global Array object.

Tuj read through the reference on objects and found it super nasty. Tuj couldn't accept the new construct. Tuj disliked the examples of Employee and Manager etc. Can we get a real world example instead? :3