Why do you have a 2nd arg in your lambda called undefined?

Also, you will want to check for the existence of 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 <[email protected]> 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/[email protected]/



To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/



To unsubscribe from this group, send email to

[email protected]


-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to