Reputation: 24536
I have the following:
var catCreyz = function() { console.log('maaaow'); }.call()
and when I test its type:
typeof catCreyz
The result returned is:
undefined
Why?
Upvotes: 1
Views: 94
Reputation: 17279
Function.prototype.call returns what the function being called returns. Your function returns nothing
var catCreyz = function() { console.log('maaaow'); }.call()
//logs undefined
console.log(catCreyz);
var result = function() { return "foo"; }.call()
//logs foo
console.log(result);
var myFunc = function() { console.log('maaaow'); }
//logs the function
console.log(myFunc);
Upvotes: 4
Reputation: 2338
Call executes the function, and you're missing a return statement in your function, Javascript does not return the last expression like other languages. You must explicitly return a value, else you get undefined.
If you want an instance of catCreyz, then take the call() off the expression.
Upvotes: 1