简体   繁体   中英

why is console.log not working inside .each?

I tried doing the following:

$('.not-following').each(function(i, obj) { 
      console.log('test');
});

for some reason it keeps on printing the obj instead of test. Any reason why this is? I tried running this on here

They overwritten console

> console.log.toString()
"function (){}"

It isn't printing the object instead, what you are seeing is the jQuery (array of nodes) that the .each() function returns.

The reason console.log() is not working is that Twitter has replaced the method with an empty function, as console.log in production is considered bad practice.

If you need to access console.log you can delete the 'overridden' version that the Twitter developers have written by invoking:

delete console.log

The will default console.log back to it's original function.

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