What Does It Do? ;jquery.ui || (function($) {
Possible Duplicate: What is the consequence of this bit of javascript? I was browsing the source code of JQuery UI. I saw this line at the beginning of the js file: ;jQuery.ui |
Solution 1:
Breaking it down:
// make sure that any previous statements are properly closed// this is handy when concatenating files, for example
;
// Call the jQuery.ui object, or, if it does not exist, create it
jQuery.ui || (function($) {
Solution 2:
Edit: Dupe of What is the consequence of this bit of javascript?
Solution 3:
The javascript || will use the first value if it evaluates as true and will use the second if the first evaluates as false.
In this case I presume it checks whether jQuery.ui exists and if it does not then it will evaluate the anonymous function. If jQuery.ui does exist then || will not evaluate the second value and so the anonymous function will not be run.
Post a Comment for "What Does It Do? ;jquery.ui || (function($) {"