Tuesday, August 30, 2011

What is the relation of "this"'s lifecycle to a javascript object lifecycle?

Sorry if the question was confusing. I am writing an JS overlay type library to our pre-existing javascript and have this question. I have a "public static native MyJSObject create()" method in my class that extends JavaScriptObject. All works great. My question is what should i be really returning in the create method? Currently, i return "this" in the js object and it works well. Earlier, I had an implementation to create a new object within my create method and then returning that and maintaining that. so, the create method would have a body like: this.myjso={};return myjso; and then all subsequent instance operations would operate on this.myjso instead of myjso.

Is there a best practice or its all the same? Thank you!!!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/UDW2SEG56FIJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment