In IE11, How to use console.log?

后端 未结 2 2005
灰色年华
灰色年华 2021-01-17 09:53

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

2条回答
  •  生来不讨喜
    2021-01-17 10:39

    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    
    

提交回复
热议问题