console.log

What is console.log?

家住魔仙堡 提交于 2019-11-25 21:57:19
问题 What is the use of console.log ? Please explain how to use it in JavaScript, with a code example. 回答1: It's not a jQuery feature but a feature for debugging purposes. You can for instance log something to the console when something happens. For instance: $('#someButton').click(function() { console.log('#someButton was clicked'); // do something }); You'd then see #someButton was clicked in Firebug’s “Console” tab (or another tool’s console — e.g. Chrome’s Web Inspector) when you would click

Google Chrome console.log() inconsistency with objects and arrays

余生长醉 提交于 2019-11-25 19:33:30
I was helping a colleague debug some code today and I noticed a strange behavior with console.log() in Google Chrome: It appears that if you: Create a nested array (e.g., [[345,"test"]]) Log the array to the console with console.log() . Modify one of the inner array values, then console.log() will output the later value -- not the values of the array at the time the console.log() was executed. JavaScript : var test = [[2345235345,"test"]] console.log(test); test[0][0] = 1111111; // outputs: [[1111111,"test"]] var testb = {}; testb.test = "test"; console.log(testb); testb.test = "sdfgsdfg"; //