How to Use Array Push Key Value using Node Js?

Jan 03, 2022 . Admin



Hello Friends,

Now let's see example of how to use array push key value example. We will check how to use array push key value. This is a short guide on use array push key value in node js. Let's get started with how to use array push key value in node js.

Here i will give you many example how to use array push key value using node js.

Example 1 :

Step 1 : Create Node App

Run following command to create node app.

mkdir my-app
cd my-app
 
npm init
Step 2 : Create server.js file

server.js

var temp = {
    sub1: "laravel",
    sub2: "node js"
};

console.log(temp);

now you can simply run by following command:

node server.js
Output :
{ sub1: 'laravel', sub2: 'node js' }

Example 2 :

Step 1 : Create Node App

Run following command to create node app.

mkdir my-app
cd my-app
 
npm init
Step 2 : Create server.js file

server.js

var temp = {
    pro1: "laptop",
    pro2: "computer"
};

temp.pro3 = "phone";

console.log(temp);

now you can simply run by following command:

node server.js
Output :
{ pro1: 'laptop', pro2: 'computer', pro3: 'phone' }

It will help you...

#Node JS