在阅读javascript代码时,我一直看到! operator used for non boolean variables. Here is an example of code not used in.
/**
* loads a resource from a url
* @param {string} url the url of the resource to load
* @param {string} relativeTo the url to load relative to
* @param {function} callback thefunction to call once the file is loaded
* @private
*/
GLGE.Wavefront.prototype.loadFile=function(url,relativeTo,callback){
if(this.relativeTo && !relativeTo) relativeTo=this.relativeTo; //<-- used on a string?
else this.relativeTo=url;
if(!callback) callback=this.loaded; //<-- used on a function? …Run Code Online (Sandbox Code Playgroud)