简体   繁体   中英

A bug of console.log() in IE11 under IE9 mode and below

I found console.log() in IE11 under IE9 mode and below works wierd. If I create an empty object, then log it, it will show 'undefined', but by alerting it shows correctly. Is this happen to you guys, or just me?

var a ={};
a.b = false;
a.c = true;
console.log(a);  //undefined
console.log(a.b);  //undefined
console.log(a.c);  //true
alert(a); //[object Object]
alert(a.b); //false
alert(a.c); //true

I am not able to reproduce the issue using the F12 console in IE9 document mode.

Could you perhaps be looking at the return value instead of the printed message?

When you run the following code from the console:

var a = {}; console.log(a);

It will print the message in blue:

> [object Object] {}

And then display the return value to console.log in green:

undefined

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM