Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I can see many place used console.log(). Can anyone tell me why it is used?

Something like this,

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.                     
    }
}
like image 810
Mr.T.K Avatar asked Jul 11 '11 11:07

Mr.T.K


People also ask

What is the purpose of a console log?

The console.log() is a function in JavaScript that is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user. Syntax: console.log(" "); Parameters: It accepts a parameter that can be an array, an object, or any message.

What is the use of console log in Salesforce?

It shows the source of an operation, what triggered the operation, and what occurred next. Use this tool to inspect debug logs that include database events, Apex processing, workflow, and validation logic. To learn more about working with logs in the Developer Console, see Log Inspector in the Salesforce online help.

Do console logs affect performance?

We already know that logging is affecting performance, especially when we use console. log because its a syncronous process. In nodejs, we have to use asyncronous process to get the best performance.

What does console log do in Python?

log is used mainly for debugging. It is used to display something on the console.


2 Answers

It logs things to a debug console (which is built into many browsers (e.g. Chrome Developer Tools) and available as an extension (e.g. Firebug for Firefox) in many others)

like image 181
Quentin Avatar answered Sep 19 '22 12:09

Quentin


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

like image 27
Neil Avatar answered Sep 19 '22 12:09

Neil