David, to be perfectly honest, I copy that single line from jQuery
framework. It is a way of jQuery making sure that absolutely no one is
messing with the undefined value. (think all the jQuery users playing
around the code and modifying undefined, then breaking jQuery
altogether.)

As for the console.log, I do have a way to check if the browser has
it, otherwise build a dummy object:

/*
 * In case we forget to remove console traces, create a dummy one for
IE and similar browsers.
 */
if( typeof window.console === "undefined" ){
  window.console={};
  var i,max,
funcs=['log','debug','table','info','warn','error','assert','dir','dirxml','trace','group','groupCollapsed','groupEnd','time','timeEnd','profile','profileEnd','count'];
  for(i=0, max=funcs.length; i<max; i++){
    console[funcs[i]] = function(){}
  }
};



On Jul 4, 6:51 pm, "David Marrs" <d.ma...@gmail.com> wrote:
> Why do you have a 2nd arg in your lambda called undefined?
>
> Also, you will want to check for the existence of&nbsp;console.log before you 
> call it, otherwise you will get a runtime error if firebug is switched off.
>
> On 4 Jul 2011 20:30, Sam3k &lt;srolda...@gmail.com&gt; wrote:
>
> Why does the following script works within the application code but it
>
> doesn't when I type it in the firebug console. It throws the following
>
> error:
>
> TypeError: debug.log is not a function
>
> My goal with this script is to make an object from where I can log
>
> things to the console, store javascript speed performance in different
>
> areas, and turn off if no cookie is set.
>
> file: Debugger.js
>
> (function (window, undefined) {
>
>   function Debugger() {
>
>     this.test = 'xxxxxx';
>
>   }
>
>     Debugger.prototype.log = function(data) {
>
>       console.log(data);
>
>     }
>
>   var _debug = new Debugger();
>
>   window.debug = _debug;
>
>   debug.log('DEFE"DEFEF');  // this works
>
> })(window);
>
> debug.log('OUTSIDE DKEGFYG');  // this works too
>
> Also any constructive feedback is greatly appreciate it.
>
> --
>
> To view archived discussions from the original JSMentors Mailman list: 
> http://www.mail-archive.com/jsment...@jsmentors.com/
>
> To search via a non-Google archive, visit 
> here:http://www.mail-archive.com/jsmentors@googlegroups.com/
>
> To unsubscribe from this group, send email to
>
> jsmentors+unsubscr...@googlegroups.com

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to