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
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
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.