Thursday, 8 August 2013

Simple Javascript Object and "this"

Simple Javascript Object and "this"

Quick question. Why does the following give a this.testFunction is not a
function error?
Test = {
data: true,
testFunction: function() {
this.data = true;
},
initialize: function() {
this.data = false;
this.testFunction();
console.log(this.data);
}
};
$(document).ready(Test.initialize);

No comments:

Post a Comment