Skip to content Skip to sidebar Skip to footer

Variable "is Not Defined" Error, Why

I have defined a object in a js file: myobj.js MyObj={ test: { value: {a: 10, b: 7}, startTest: function(){ var x = this.value.a; var y = this.value

Solution 1:

mytest = MyObj.test.startTest

This gives you a function without context. If you call this function directly then this is window.

You want to all test.startTest() so that this is test

An excellent guide on this

Post a Comment for "Variable "is Not Defined" Error, Why"