While reading through javascript codes I've been seeing the ! 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? var req = new XMLHttpRequest(); if(req) { // request handling code } }; req.open("GET", url, true); req.send(""); } } In this library I've seen many uses of this operator in this manner.
Can someone explain how/if the 'not' function of a string, object or function can be determined when it isn't one half of a Boolean set like the set; true and false?