Node.js console.log() Function - GeeksforGeeks (2024)

Skip to content

  • Courses
    • Newly Launched!
    • For Working Professionals
    • For Students
    • GATE Exam Courses
  • Tutorials
    • Data Structures & Algorithms
      • Data Structures
        • Tree
  • Full Stack Course
  • NodeJS Tutorial
  • NodeJS Exercises
  • NodeJS Assert
  • NodeJS Buffer
  • NodeJS Console
  • NodeJS Crypto
  • NodeJS DNS
  • NodeJS File System
  • NodeJS Globals
  • NodeJS HTTP
  • NodeJS HTTP2
  • NodeJS OS
  • NodeJS Path
  • NodeJS Process
  • NodeJS Query String
  • NodeJS Stream
  • NodeJS String Decoder
  • NodeJS Timers
  • NodeJS URL
  • NodeJS Interview Questions
  • NodeJS Questions
  • Web Technology

Open In App

Last Updated : 14 Oct, 2021

Summarize

Comments

Improve

The console.log() function from console class of Node.js is used to display the messages on the console. It prints to stdout with newline.

Syntax:

console.log( [data][, ...] )

Parameter: This function contains multiple parameters which are to be printed.

Return type: The function returns the passed parameters.

Below program demonstrates the working of console.log() function:

Program 1:

function GFG(name) {

console.log("hello " + name);

}

// when parameters are passed

GFG("Geeksforgeeks");

Output:
Node.js console.log() Function - GeeksforGeeks (3)

Program 2:

function GFG(name) {

console.log("hello " + name);

}

// No parameters are passed

GFG();

Output:
Node.js console.log() Function - GeeksforGeeks (4)



T

Twinkl Bajaj

Node.js console.log() Function - GeeksforGeeks (5)

Improve

Next Article

Node.js console.warn() Function

Please Login to comment...

Similar Reads

Difference between console.dir and console.log Console Object: The Console object provides access to the browser's debugging console, which can be seen using F12 or ctrl+shift+j. Console object contains many methods, log() and dir() are most used among. The console.log() method prints out a toString representation of the object in the console to the user. Syntax: console.log(object) or console. 2 min read Difference between process.stdout.write and console.log in Node JS Both process.stdout.write and console.log in Node JS have basic functionality to display messages on the console. Basically console.log implement process.stdout.write while process.stdout.write is a buffer/stream that will directly output in our console. Difference between process.stdout.write and console.log in Node JS are:Sr. no.process.stdout.wr 2 min read What is the use of the console.log() Function in JavaScript? The console.log() function serves as a fundamental tool for developers to output information to the console. It plays a crucial role in the debugging process, allowing programmers to inspect variables, log messages, and trace the flow of their code. By printing relevant data to the console, developers can gain insights into the state of their progr 1 min read Difference Between console.time and console.timeEnd in JavaScript In JavaScript, console.time and console.timeEnd are powerful tools used for performance measurement. These methods allow developers to measure the time a block of code takes to execute, which is particularly useful for optimizing performance and debugging. Table of Content What is console. time?What is console.timeEnd?Difference Between console.tim 2 min read How to use console.log() for multiple variables In JavaScript, console.log() is a method that is used to print values or output any message to the console of the browser. To view the console of the browser we press F12 keyboard key shortcut in the browser. This method is mainly used by developers for testing or debugging purpose. In this article we will discuss various methods to display multipl 2 min read Difference Between alert and console.log in JavaScript In JavaScript, alert and console.log are two commonly used methods for the displaying information to the user or the developer. While both the serve the purpose of the outputting data they have different use cases and characteristics. This article explores the differences between the alert and console.log. In this article we are going to discuss th 3 min read HTML DOM console log() Method The console.log() method in HTML is used for writing a message in the console. It indicates an important message during the testing of any program. The message is sent as a parameter to the console.log() method. Syntaxconsole.log( message )ParametersParameter Description message It is mandatory and used to specify the information to be written on 2 min read JavaScript console.log() Method The console.log() method in JavaScript logs messages or data to the console. The console.log() method is useful for debugging or testing purposes. Syntax:console.log("");Parameters: Any message either number, string, array object, etc. Return value: It returns the value of the parameter given. Using Console.log()Using the console.log() to print a s 2 min read Node.js console.warn() Function The console.warn() function from console class of Node.js is used to display the warning messages on the console. It prints to stderr with newline. Note: This function is an alias of console.error() function. Syntax: console.warn( [data][, ...args] ) Parameter: This function can contains multiple parameters. The first parameter is used for the prim 1 min read Node.js console.error() Function The console.error() function from the console class of Node.js is used to display an error message on the console. It prints to stderr with a newline. Syntax: console.error([data][, ...args]) Parameter: This function can contain multiple parameters. The first parameter is used for the primary message and other parameters are used for substitution v 1 min read Node.js console.dir() Method The console.dir() method is used to get the list of object properties of a specified object. These object properties also have child objects, from which you can inspect for further information. Syntax: console.dir( object ) Parameters: This method accepts single parameter which holds the object element. Example 1: <!DOCTYPE html> <html> 1 min read Node.js console.timeEnd() Method The console.timeEnd() method is the console class of Node.js. This method stops a timer that was previously started by using console.time() method and display the result using stdout. Syntax: console.timeEnd( label ) Parameter: This method accepts a single parameter label that holds the string value. If the label is not passed i.e the value of the 2 min read Node.js console.time() Method The console.time() method is the console class of Node.js. It is used to starts a timer that is used to compute the time taken by a piece of code or function. The method console.timeEnd() is used to stop the timer and output the elapsed time in milliseconds to stdout. The timer can be accurate to the sub-millisecond. Syntax console.time( label ) Pa 3 min read Node.js console.clear() Method The console.clear() method is used to clear the stdout, when stdout is a TTY (Teletype) i.e. terminal it will attempt to clear the TTY. When stdout is not a TTY, this method does nothing. The console.clear() will work differently across different operating systems and terminal types. For Linux operating systems, console.clear() operates like the cl 1 min read How to configure node.js console font ? You can format the console font in Node.js using the CHALK module. The chalk module is can be used to customize node console. By using it, one can change the console look using features of it like bold the text, making underlines, highlighting the background color of a text, etc. Features of Chalk module: It's easy to get started and easy to use.It 2 min read Node.js console.assert() Method The console.assert() method is an inbuilt application programming interface of the console module which is used to assert value passed to it as a parameter, i.e. it checks whether the value is true or not, and prints an error message, if provided and failed to assert the value. Syntax: console.assert(value, messages) Parameters: This method has two 2 min read Node.js console.count() Method The console.count() method is an inbuilt application programming interface of the console module which is used to count label passed to it as a parameter, by maintaining an internal counter for that specific label. Syntax: console.count(label) Parameters: This method has one parameter as mentioned above and described below: label: It is an optional 2 min read Node.js console.timeLog() Method The console.timeLog() method is an inbuilt function in Nodejs that is used to display the time for each execution. This function is proved to be effective when used in a loop. Syntax: console.log([label][, ...data]) Parameters: This function accepts two or more parameters. Return Value: This method displays the time for the execution. Below example 1 min read Node.js console.countReset() Method The console.countReset() method is an inbuilt application programming interface of the console module which is used to reset the count for the specific label passed to it as a parameter. Syntax: console.countReset( label ); Parameters: This method has one parameter as mentioned above and described below: label: It is an optional parameter that spec 2 min read Node.js console.trace() Method The console.trace() method is an inbuilt application programming interface of the console module which is used to print stack trace messages to stderr in a newline. Similar to console.error() method. Syntax: console.trace(message, args); Parameters: This method has two parameters as mentioned above and described below: message: This parameter speci 2 min read Node.js console.debug() Method The console.debug() method is an inbuilt application programming interface of the console module which is used to print messages to stdout in a newline. Similar to the console.log() method. Syntax: console.debug(data, args); Parameters: This method has two parameters as mentioned above and described below: data: This parameter specifies the data to 2 min read Node.js console.info() Method The console.info() method is an inbuilt application programming interface of the console module which is used to print messages to stdout in a newline. It is similar to the console.log() method. Syntax: console.info(data, args); Parameters: This method has two parameters as mentioned above and described below: data: This parameter specifies the dat 2 min read Node.js console.table() Method The console.table() method is an inbuilt application programming interface of the console module which is used to print the table constructed from it's parameters into the console. Syntax: console.table(data, properties); Parameters: This method accept two parameters as mentioned above and described below: data: Tabular data. An array of each row d 2 min read Node.js new Console() Method The console module provides a simple debugging console that is provided by web browsers which export two specific components: A Console class that can be used to write to any Node.js stream. Example: console.log(), console.error(), etc.A global console that can be used without importing console. Example: process.stdout, process.stderr, etc. The new 4 min read Node.js console.profileEnd() Method The console module provides a simple debugging console that is provided by web browsers which export two specific components: The console class can be used to write to any Node.js stream. Example: console.log(), console.error(), etc.A global console can be used without importing a console. Example: process.stdout, process.stderr, etc. The console.p 2 min read Node.js console.profile() Method The console module provides a simple debugging console that is provided by web browsers which export two specific components: A Console class that can be used to write to any Node.js stream. Example: console.log(), console.error(), etc.A global console that can be used without importing the console. Example: process.stdout, process.stderr, etc. The 2 min read Node.js console.timeStamp() Method The console module provides a simple debugging console that is provided by web browsers which export two specific components: A Console class that can be used to write to any Node.js stream. Example: console.log(), console.error(), etc.A global console that can be used without importing the console. Example: process.stdout, process.stderr, etc. The 2 min read Node.js console.group() Method The console. group() method is an inbuilt application programming interface of the console module which is used to print passed content in a grouped style. It indicates the start of a message group. To end this group we can use console. groupEnd() method. Syntax: console.group([label]); Parameters: This method accepts only one parameter as mentione 3 min read Node.js console.groupEnd() Method The console. groupEnd() method is an inbuilt application programming interface of the console module which is used to end the started group by calling method console.group() or console.groupCollapsed(). It indicates the end of a message group. Syntax: console.groupEnd(); Parameters: This method doesn't accept any parameter. Return Value: This metho 3 min read Node.js console.groupCollapsed() Method The console.groupCollapsed() method is inbuilt of the console module which is used to collapse the grouped content until call the console.groupEnd() method. It starts the collapsed group and can be ended with groupEnd() method. Syntax: console.groupCollapsed([label]); Parameters: This method accepts only one parameter as mentioned above and describ 2 min read

Article Tags :

  • Node.js
  • Web Technologies
  • NodeJS-function

Trending in News

View More
  • How to Merge Cells in Google Sheets: Step by Step Guide
  • How to Lock Cells in Google Sheets : Step by Step Guide
  • #geekstreak2024 – 21 Days POTD Challenge Powered By Deutsche Bank

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy

Node.js console.log() Function - GeeksforGeeks (6)

'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, check: true }), success:function(result) { jQuery.ajax({ url: writeApiUrl + 'suggestions/auth/' + `${post_id}/`, type: "GET", dataType: 'json', xhrFields: { withCredentials: true }, success: function (result) { $('.spinner-loading-overlay:eq(0)').remove(); var commentArray = result; if(commentArray === null || commentArray.length === 0) { // when no reason is availaible then user will redirected directly make the improvment. // call to api create-improvement-post $('body').append('

'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.unlocked-status--improve-modal-content').css("display","none"); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); return; } var improvement_reason_html = ""; for(var comment of commentArray) { // loop creating improvement reason list markup var comment_id = comment['id']; var comment_text = comment['suggestion']; improvement_reason_html += `

${comment_text}

`; } $('.improvement-reasons_wrapper').html(improvement_reason_html); $('.improvement-bottom-btn').html("Create Improvement"); $('.improve-modal--improvement').hide(); $('.improvement-reason-modal').show(); }, error: function(e){ $('.spinner-loading-overlay:eq(0)').remove(); // stop loader when ajax failed; }, }); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); } else { if(loginData && !loginData.isLoggedIn) { $('.improve-modal--overlay').hide(); if ($('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { $('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } } }); $('.left-arrow-icon_wrapper').on('click',function(){ if($('.improve-modal--suggestion').is(":visible")) $('.improve-modal--suggestion').hide(); else{ $('.improvement-reason-modal').hide(); } $('.improve-modal--improvement').show(); }); function loadScript(src, callback) { var script = document.createElement('script'); script.src = src; script.onload = callback; document.head.appendChild(script); } function suggestionCall() { var suggest_val = $.trim($("#suggestion-section-textarea").val()); var array_String= suggest_val.split(" ") var gCaptchaToken = $("#g-recaptcha-response-suggestion-form").val(); var error_msg = false; if(suggest_val != "" && array_String.length >=4){ if(suggest_val.length <= 2000){ var payload = { "gfg_post_id" : `${post_id}`, "suggestion" : `

${suggest_val}

`, } if(!loginData || !loginData.isLoggedIn) // User is not logged in payload["g-recaptcha-token"] = gCaptchaToken jQuery.ajax({ type:'post', url: "https://apiwrite.geeksforgeeks.org/suggestions/auth/create/", xhrFields: { withCredentials: true }, crossDomain: true, contentType:'application/json', data: JSON.stringify(payload), success:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-section-textarea').val(""); jQuery('.suggest-bottom-btn').css("display","none"); // Update the modal content const modalSection = document.querySelector('.suggestion-modal-section'); modalSection.innerHTML = `

Thank You!

Your suggestions are valuable to us.

You can now also contribute to the GeeksforGeeks community by creating improvement and help your fellow geeks.

`; }, error:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Something went wrong."); jQuery('#suggestion-modal-alert').show(); error_msg = true; } }); } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Minimum 5 Words and Maximum Character limit is 2000."); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Enter atleast four words !"); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } if(error_msg){ setTimeout(() => { jQuery('#suggestion-section-textarea').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } } document.querySelector('.suggest-bottom-btn').addEventListener('click', function(){ jQuery('body').append('

'); jQuery('.spinner-loading-overlay').show(); if(loginData && loginData.isLoggedIn) { suggestionCall(); return; } // load the captcha script and set the token loadScript('https://www.google.com/recaptcha/api.js?render=6LdMFNUZAAAAAIuRtzg0piOT-qXCbDF-iQiUi9KY',[], function() { setGoogleRecaptcha(); }); }); $('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked $('body').append('

'); $('.spinner-loading-overlay').show(); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.improvement-reason-modal').hide(); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); });

Node.js console.log() Function - GeeksforGeeks (2024)
Top Articles
Security Tips for Choosing Security Questions and Answers
What to do if you forgot your security question answers
Www.mytotalrewards/Rtx
Restored Republic January 20 2023
No Limit Telegram Channel
Readyset Ochsner.org
Arrests reported by Yuba County Sheriff
Mail Healthcare Uiowa
Kentucky Downs Entries Today
AB Solutions Portal | Login
Devourer Of Gods Resprite
B67 Bus Time
Cube Combination Wiki Roblox
Connexus Outage Map
Craigslist Deming
Hoe kom ik bij mijn medische gegevens van de huisarts? - HKN Huisartsen
Panorama Charter Portal
The Exorcist: Believer (2023) Showtimes
H12 Weidian
VERHUURD: Barentszstraat 12 in 'S-Gravenhage 2518 XG: Woonhuis.
Geometry Review Quiz 5 Answer Key
Www Craigslist Com Bakersfield
Diakimeko Leaks
Clare Briggs Guzman
Panolian Batesville Ms Obituaries 2022
Amazing Lash Studio Casa Linda
Routing Number For Radiant Credit Union
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Downtown Dispensary Promo Code
Worthington Industries Red Jacket
Bursar.okstate.edu
Life Insurance Policies | New York Life
Mkvcinemas Movies Free Download
Police Academy Butler Tech
American Bully Xxl Black Panther
Avance Primary Care Morrisville
Pepsi Collaboration
Spn-523318
My Locker Ausd
How to Get a Better Signal on Your iPhone or Android Smartphone
Gym Assistant Manager Salary
Energy Management and Control System Expert (f/m/d) for Battery Storage Systems | StudySmarter - Talents
Lucifer Morningstar Wiki
Pulaski County Ky Mugshots Busted Newspaper
Top 1,000 Girl Names for Your Baby Girl in 2024 | Pampers
Tacos Diego Hugoton Ks
25 Hotels TRULY CLOSEST to Woollett Aquatics Center, Irvine, CA
Rovert Wrestling
O'reilly's On Marbach
Verilife Williamsport Reviews
Ravenna Greataxe
Latest Posts
Article information

Author: Virgilio Hermann JD

Last Updated:

Views: 5906

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Virgilio Hermann JD

Birthday: 1997-12-21

Address: 6946 Schoen Cove, Sipesshire, MO 55944

Phone: +3763365785260

Job: Accounting Engineer

Hobby: Web surfing, Rafting, Dowsing, Stand-up comedy, Ghost hunting, Swimming, Amateur radio

Introduction: My name is Virgilio Hermann JD, I am a fine, gifted, beautiful, encouraging, kind, talented, zealous person who loves writing and wants to share my knowledge and understanding with you.