I made an array to be passed in apply method, I was expecting to return full value of array, but when I used index value of array to give value of that index, array method actually returned index of character:
var obj = {
name: 'Dogs'
}
var arr = ['India', 'Slovenia', 'Scotland'];
var getanimalsinfo = function(a) {
return this.name + ' is good animal found in ' + a[2]
}
console.log(getanimalsinfo.apply(obj, arr));
Here, I was expecting "Dog is good animal found in Scotland", but I got : 'Dog is good animal found in d'. Here d is the third index of India. Please let me know what I did wrong. Thanks.