How to Use Array Length using Node Js?
Jan 01, 2022 . Admin

Hello Friends,
Now let's see example of how to use array length example. We will check how to use array length. This is a short guide on use array length in node js. Let's get started with how to use array length in node js.
Here i will give you many example how to use array length using node js.
Example 1 :
Run following command to create node app.
mkdir my-app cd my-app npm initStep 2 : Create server.js file
server.js
const subjects = ['laravel', 'node js', 'JavaScript', 'php']; console.log(subjects.length);
now you can simply run by following command:
node server.jsOutput :
4
Example 2 :
Step 1 : Create Node AppRun following command to create node app.
mkdir my-app cd my-app npm initStep 2 : Create server.js file
server.js
var Subjects = ["laravel", "node js", "php", "css", "html"]; if (Subjects.length > 3) { Subjects.length = 3; } console.log(Subjects.length);
now you can simply run by following command:
node server.jsOutput :
3
It will help you...