Navigate back to the homepage

how to get length of string in node js?

Infinitbility
Node
July 7th, 2022 · 1 min read
how to get length of string in node js?

Hi Friends 👋,

Welcome To Infinitbility! ❤️

To get length of string in node js, use the String length property it will return your string char count.

The length property of a String object contains the length of the string, in UTF-16 code units. length is a read-only data property of string instances.

In the following example, we will take the sample string and use string length to get a count of the string.

1let str = "infinitbility";
2
3console.log(str.length) // 13

Today, I’m going to show you How do i find the length of a string in node js, as mentioned above here, I’m going to use the use String length property.

Let’s start today’s tutorial how do you get the length of the string in node js?

In this example, we will do

  1. take an example of a string variable
  2. use the string length property
  3. print the length of string on the page screen
1var http = require("http");
2
3//create a server object:
4http
5 .createServer(function (req, res) {
6 let str = "infinitbility";
7
8 res.write("infinitbility string length is " + str.length); //write a response to the client
9 res.end(); //end the response
10 })
11 .listen(8080); //the server object listens on port 8080

In the above node js example, we have taken the sample string variable, find the string length, and return the response.

I hope it helps you, All the best 👍.

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

node js convert string to number

node js convert string to number

An example of convert string to int in node js with a step-by-step example.

July 7th, 2022 · 1 min read
how to remove double quotes from string in react native?

how to remove double quotes from string in react native?

An example of remove double quotes from string in react native with step by step guide.

July 6th, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]