Omirion Posted January 11, 2011 Share Posted January 11, 2011 Hey guys, So in short check the code out. var objJSON = { first: 'something' func:function(){ //where does THIS point to? } obj:{ something:'foo' func2:function(){ //Where does this point to here } } } So basically i want to know how this ties into JSON. Does it always point to the root object? And if so how can i set up callpoints. like lets say i have a multi levele object m{ a:{ b:{ } c:{ } } } How can i set a callpoint that points to a rather than the root element m. Quote Link to comment https://forums.phpfreaks.com/topic/224132-what-is-this-in-json/ Share on other sites More sharing options...
trq Posted January 12, 2011 Share Posted January 12, 2011 Json cannot contain functions, only strings, numbers, arrays and more Json objects. What you have actually created is a Javascript object. I'm not sure what you mean by callpoints? Quote Link to comment https://forums.phpfreaks.com/topic/224132-what-is-this-in-json/#findComment-1158155 Share on other sites More sharing options...
Omirion Posted January 12, 2011 Author Share Posted January 12, 2011 That's what i meant. In an object created with JSON notation. Ok forget the callpoints , where does THIS point to in the diffrent levels and in the functions Quote Link to comment https://forums.phpfreaks.com/topic/224132-what-is-this-in-json/#findComment-1158157 Share on other sites More sharing options...
trq Posted January 12, 2011 Share Posted January 12, 2011 That's what i meant. In an object created with JSON notation. Ah, now I'm with you. var objJSON = { first: 'something', func:function(){ // this would point to ObjJSON }, obj:{ something:'foo', func2:function(){ // this would point to obj } } } Quote Link to comment https://forums.phpfreaks.com/topic/224132-what-is-this-in-json/#findComment-1158163 Share on other sites More sharing options...
Omirion Posted January 12, 2011 Author Share Posted January 12, 2011 Thank you ^^ Quote Link to comment https://forums.phpfreaks.com/topic/224132-what-is-this-in-json/#findComment-1158201 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.