Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 754671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:02:27+00:00 2026-05-14T15:02:27+00:00

I have some Firebug console function calls that I wanted to disable when Firebug

  • 0

I have some Firebug console function calls that I wanted to disable when Firebug wasn’t enabled, e.g. console isn’t defined. This works fine in IE6 and FF3, but not in Chrome:

var log;

if(console){
  log = console.log;
}else{
  log = function(){ return; }
}

I get an “Uncaught TypeError: Illegal Invocation” in Chrome =/

I read about the issue here, where you have to apply a context, which is kind of new to me… and I can’t seem to figure how to accomplish the above in all browsers…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:02:27+00:00Added an answer on May 14, 2026 at 3:02 pm

    Yes, you should persist the context :

    var log;
    
    if (window.console && typeof console.log === "function"){
      // use apply to preserve context and invocations with multiple arguments
      log = function () { console.log.apply(console, arguments); };
    } else {
      log = function(){ return; }
    }
    

    What is happening is that the context (the this value), is implicitly set when you call a function, for example:

    var obj = {
      method: function () { return this; }
    };
    
    obj.method() === obj; // true
    

    In this case, you are calling a function that is defined as a property of an object, when the function is invoked, the this value is set to that object.

    Now as in your example, if you copy a reference of that method to a variable:

    var method = obj.method;
    method() === window; // global object
    

    As you can see, the this value refers to the global object.

    So, to avoid this implicit behavior you can set the context explicitly, with the call or apply functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer // Allocate a new buffer (skip this if you already… May 16, 2026 at 9:53 am
  • Editorial Team
    Editorial Team added an answer I think // for truncation is reasonably well known, but… May 16, 2026 at 9:53 am
  • Editorial Team
    Editorial Team added an answer When a user visits a page, you want to log… May 16, 2026 at 9:53 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a Greasemonkey script that works just fine in Firefox and Opera. I
I have an application that has this format scattered around but I dont know
I have some javascript code that is used in a few different pages in
I have some automatic de-serialization code that will set an object's properties using KVC
I have some trivial markup that looks like the following: <li class=someclass> <=% t'model.attr'
I have a bit of JavaScript code that is specified in a configuration file
I have debugged through JavaScript using Firebug more than hundred times without worrying about
I am trying to grab some data via JSONP. Using Firebug, I am able
I have enabled SSL and I am doing a jQuery AJAX post request and
I have some objects which I draw onto a Canvas as part of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.