Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • 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
Next Article:
How to build your own CLI (Command Line Interface) with Node.js ?
Next article icon

How to print console without trailing newline in Node.js ?

Last Updated : 07 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In Node.js, console.log() method is used to display the message on the console. By default, the console.log() method prints on console with trailing newline.

Example 1:




// Node.js program to demonstrate the   
// console.log() Method
  
console.log("Welcome to GeeksforGeeks! ");
console.log("A computer science portal for geeks");
 
 

Output:

Welcome to GeeksforGeeks!  A computer science portal for geeks

In the above example, Welcome to GeeksforGeeks! printed on first line and A computer science portal for geeks printed on second line.
But sometimes we may need to print the console without trailing newline. In that case, we can use process.stdout.write() method to print to console without trailing newline.

Example 2:




// Node.js program to demonstrate the   
// process.stdout.write() Method
  
process.stdout.write("Welcome to GeeksforGeeks! ");
process.stdout.write("A computer science portal for geeks");
 
 

Output:

Welcome to GeeksforGeeks! A computer science portal for geeks

Note: The process object is global so it can be used without using require() method.



Next Article
How to build your own CLI (Command Line Interface) with Node.js ?

D

DivyaRani1
Improve
Article Tags :
  • JavaScript
  • Node.js
  • Web Technologies
  • Node.js-Misc

Similar Reads

  • How to Add Two Numbers in Console using Node.js ?
    Adding two numbers using Node.js is a basic task that helps in understanding how to handle user input and process data within the Node.js environment. By following the steps in this guide, you'll learn how to create a simple Node.js application that reads numbers from the console, performs an additi
    2 min read
  • What is stacktrace and how to print in node.js ?
    Stacktrace in Node is a report that displays the error along with the path or sequence of execution. It provides the sequence of function calls or operations that led to an error in a program. It helps to debug the issues by providing the path of execution. A Stack trace is displayed automatically b
    3 min read
  • How to Show the Line which Cause the Error in Node.js ?
    Debugging is a critical part of software development. When an error occurs in a Node.js application, understanding exactly where it happened is essential for diagnosing and fixing the problem. Node.js provides several ways to pinpoint the line of code that caused an error. This article explores thes
    4 min read
  • How to print command line arguments passed to the script in Node.js ?
    Node.js is an open-source and cross-platform runtime environment built on Chrome's V8 engine that enables us to use JavaScript outside the browser. Node.js helps us to use build server-side applications using JavaScript.  In Node.js if you want to print the command line arguments then we can access
    2 min read
  • How to build your own CLI (Command Line Interface) with Node.js ?
    Introduction: A command-line interface (CLI) is a text-based user interface (UI) for running programs, managing files, and interacting with computers. Building your own CLI is easier than you might think with Node.js. There are a bunch of open-source packages that can handle color, animation, and us
    2 min read
  • How to Print to Console an Object in a MongoDB Script?
    MongoDB queries can sometimes be slow, especially when dealing with large datasets or complex queries. So there are some methods or approaches that allow the developers to check the data and spot mistakes during the program run. In this article, we will learn about How to Print to Console an Object
    3 min read
  • How To Read a File Line By Line Using Node.js?
    To read a file line by line in Node.js, there are several approaches that efficiently handle large files and minimize memory usage. In this article, we'll explore two popular approaches: using the Readline module (which is built into Node.js) and using the Line-reader module, a third-party package.
    3 min read
  • How to read and write JSON file using Node ?
    Node JS is a free and versatile runtime environment that allows the execution of JavaScript code outside of web browsers. It finds extensive usage in creating APIs and microservices, catering to the needs of both small startups and large enterprises. JSON(JavaScript Object Notation) is a simple and
    3 min read
  • How to return an array of lines from a file in node.js ?
    In this article, we will return an array of lines from a specified file using node.js. The fs module is used to deal with the file system in node.js and to read file data we use fs.readFileSync( ) or fs.readFile( ) methods. Here we will use the readFileSync method to read the file, and we use the st
    2 min read
  • How to Print a String in JavaScript ?
    In JavaScript, printing a string means displaying the contents of a string variable or literal to the console, webpage, or any other output medium. Strings are a fundamental data type in JavaScript, representing sequences of characters enclosed within single ('') or double ("") quotes. Table of Cont
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
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
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences