Add Comment
|
Related Links
|
TrackBack
YouOS Programming Pitfall #1 - this objectProgramming on YouOS is really the first time that I programmed in JavaScript. Well, I have written Greasemonkey scripts before, which is also JavaScript. But I'm not yet a JavaScript guru, so I can't differentiate between pure JavaScript vs. Greasemonkey vs. YouOS just yet. One thing I noticed about programming JavaScript in YouOS is that the global/local scope is defined somewhat differently than scope in other languages. In other languages, such as Java or C++, global scope elements (methods and variables) can be referenced in the local scope without quantification, as long as the local scope elements doesn't overwrite global scope elements. In YouOS, local scope cannot reference global scope elements without quantification. Typically, the quantification is done with the keyword "this". bar () foo () Think of "this" as a reference to this object. In this case, it's your YouOS program. If you do not quantify "bar" in "foo", "foo" will not find "bar", and your program will not run correctly. I don't know how long I spent debugging my YouOS programs due to this rule, but I know spent a very long time. Knowing this pitfall, development and debugging are moving a lot quicker now. I don't know if this pitfall applies to all JavaScripts or only YouOS JavaScripts. Feel free to chime in if you know. Chieh Cheng
Add Comment
|
Related Links
|
TrackBack
Did your message disappear? Read the Forums FAQ. Add CommentSpam Control | * indicates required field TrackBackTrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites. Send Ping | TrackBack URL | Spam Control No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here. Messages, files, and images copyright by respective owners. |
Products
|
Services
67 Users Online
|
Copyright © 1996 - 2024. All Rights Reserved. |