What is purpose of Firebugx.js file?
It contains this - what is it for?
Code:
if (!("console" in window) || !("firebug" in console))
{
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {}
}
Re: What is purpose of Firebugx.js file?
From the Firebug Doc:
Quote:
Firebug adds a global variable named "console" to all web pages loaded in Firefox. This object contains many methods that allow you to write to the Firebug console to expose information that is flowing through your scripts.
So you can use Firebug's "console" object methods in your Javascript to further aid in debugging. But Firebug exists in Firefox - if your Javascript is littered with these methods and you view your page in another browser, there may be problems (namely: console is not defined).
So this bit of script is a fail-safe: if console is not in window, or firebug is not in console, then we're not in the "right environment" (Firefox with Firebug enabled), and we need to at least make a dummy console object with methods so that our Javascript won't blow up.
Re: What is purpose of Firebugx.js file?
Thank you very much - that was really well said - and now that I understand JS and JS objects - actually makes sense to me as well!