I'm trying to round out my Javascript knowledge. This seems like such a simple thing, yet it's puzzling me.
I have a need to store a method name as a variable. Reducing my test case to the smallest possible size, results in the following:
var someobj = {
someMethod: function() {
console.log('woo');
},
somevariable: this.someMethod
}
There are no callbacks, everything's nice and simple.
console.log(someobj.someMethod);
Returns:
[Function]
Great. But:
console.log(someobj.somevariable)
Returns:
undefined
I was expecting it to return '[Function]'. Why is this?
Thanks.