i am reading about call function in js. Now i have this code
var o = {
name: 'i am object',
age: 22
}
function saymyName(arguentToFunc) {
console.log('my name is ' + this.name + 'and thw argument passed is ' + arguentToFunc);
}
saymyName.apply(o, 'hello there');
But it gives an error message saying Uncaught TypeError: Function.prototype.apply: Arguments list has wrong type
In the book the definite guide it is written that the second argument is the value passed to the function. eg here it is hello there
So why the error?
Hey according to the book
.apply needs this
what does If a function is defined to accept an arbitrary number of arguments, mean? i mean arbritary??