I've been reading Nicholas Zakas 'The Principles of Object Oriented Javascript' and came across an example using apply(). I messed with the example and ended up having the apply method read the array as a string. I cannot explain this functionality:
function testFunction(theArray) {
console.log(Array.isArray(theArray)); // false
console.log(theArray); // string1
console.log(theArray[0]); // s
console.log(this.name); // testName
}
var person1 = {name:'testName'};
testFunction.apply(person1,['string1','string2']);
Could somebody please explain how I am getting this result and why I can't seem to access the array?
Thanks