How can you use methods of one object type against another object type? How can you use the feature to your advantage?
In another post, we had discussed how Javascript can use call
to invoke methods of a function in a different context.
We can use this feature to our advantage.
Consider a string and array -
|
|
Without explicitly converting alpha
array, we can apply string manipulation methods directly on array. Did you note that the result was a string, and we had to convert back into an array. Yes, that happened.
The reverse is also possible.
|
|