最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - In IE11, How to use console.log? - Stack Overflow

programmeradmin0浏览0评论

Try to use console.log() But it's always printting undefined.

Try to use the solutions like Console.log IE9 issue it does not work as well.

In this IE11 document, there is the following sentence: Last but not least, forget about console.log(). The new tools now support Tracepoints easily allowing you to monitor specific values the same way you would via console.log().

What does that mean? How to use console.log to print variable in IE11?


System: windows 7(VirtualBox IE images)

IE version:11


It seems console.dir() is an option, but how about console.log()? It is in the document, but why does not take effect?

Try to use console.log() But it's always printting undefined.

Try to use the solutions like Console.log IE9 issue it does not work as well.

In this IE11 document, there is the following sentence: Last but not least, forget about console.log(). The new tools now support Tracepoints easily allowing you to monitor specific values the same way you would via console.log().

What does that mean? How to use console.log to print variable in IE11?


System: windows 7(VirtualBox IE images)

IE version:11


It seems console.dir() is an option, but how about console.log()? It is in the document, but why does not take effect?

Share Improve this question edited May 23, 2017 at 10:30 CommunityBot 11 silver badge asked Mar 11, 2014 at 2:15 KamelKamel 1,8661 gold badge15 silver badges26 bronze badges 3
  • You're probably looking at the return value. The console will output the return value of the last statement it executes. – user229044 Commented Mar 11, 2014 at 2:28
  • But whatever the variable contains, the console.log() will print undefined, while console.dir() will not, why? – Kamel Commented Mar 11, 2014 at 3:06
  • 2 I have seen this before, but could not repo the issue. console.log console.info, etc all work for me normally. Do you possibly have a 3rd party library that might be changing the console object? – Chris Love Commented Mar 12, 2014 at 3:00
Add a comment  | 

2 Answers 2

Reset to default 10

Even though it's an old question, yet still giving me headache recently when working with IE11.

Simple reason: console object is not initiated unless devtools (i.e. pressing F12 in IE11) is opened.

So a workaround could be, open devtools before loading console.log().

In my case, console.log is loaded when my page is ready, so I open devtools and refresh the page to view my log.

I recently ran into issues with console.log while running the most recent preview build of Windows 10. Below is the code I was trying to log. The log would say my objects functions, proto, and users were undefined. I could "work around" this by changing my version of IE to 9 or putting a breakpoint on console.log(). As far as I can tell, they have just made the console methods more strict to conform with this documentation.

The rules I follow now is to always use console.dir() when outputting objects/variables.

  var PM = PM || {
    users:[]
  };

  var User = (function($){
    //Private Static Variables

    //Constructor
    function User(obj){
      this.id = obj.id;
      this.first = obj.first;
      this.last = obj.last;
    };

    return User;
  })(jQuery); 

  var John = new User({
    id: 1,
    first: 'John',
    last: 'Hargis'
  });
  var Nicole = new User({
    id: 2,
    first: 'Nicole',
    last: 'Hargis'
  });

  PM.users = {
    1: John,
    2: Nicole
  };
  window.console.log(PM); //Undefined
  window.console.dir(PM); //Works    
发布评论

评论列表(0)

  1. 暂无评论