Why is console.log used? What does it do?

I see a lot of space used by console.log() . Can someone tell me why it is used?

Something like that,

 function createCheckBox( idsToShow ) { for( i = 0 ; i < 15 ; i++ ) { console.log( idsToShow.indexOf('main' + i + '|' ) + ' ' + 'main' + i + '|' ); if( idsToShow != '' && idsToShow.indexOf('main' + i + '|' ) == -1 ) continue; checkBoxs += "<li> <input type=\"checkbox\" id=\"main" + i + "\" value=\"Example" + i + "\" name=\"lbl"+ i +"\" /> <label id=\"lbl"+ i +"\">Example" + i + "</label></li>"; ids += 'main' + i + '|'; //is the check box id. } } 
+6
source share
4 answers

It writes information to the debugging console (which is built into many browsers (for example, tools for Chrome developers) and is available as an extension (for example, Firebug for Firefox) in many others)

+10
source

Everyone seems to be using a log, but console.info is more useful. In Firebug, it gives the line number where it came from, so you don't need to be so descriptive in the console message. It is also much easier to track if a colleague leaves a wandering console somewhere on your site.

+1
source

console is a debugging handler found in many browsers. For more backward browsers, you can try FauxConsole .

0
source

you can use console.log to show you the log of each executed line and debugger; on a specific line to abort the script if you use firebug or any other developer tools.

0
source

Source: https://habr.com/ru/post/892480/


All Articles