Variable in JavaScript

Syntax of declaring the variable:

There are two ways of declaring the variable:

  • Declaring and defining the variable at the same time
  • Only declaring and defining in another line
var num1=10;
var strnum1='10';
//declaring
var num1;


//defining
num1=10;
//error
num1=10;


//declaring
var num1;

There are three types of keywords by which we can declare the variable:

  • var
  • let
  • const
//declaring
var num1;
console.log(num1)//undefined

//defining
num1=10;
//let keyword
let num1=9;
//declaring
const num1=12;

note:-

--

--

--

love ❤ coding, solving some industry problems technologies: JavaScript, C#, Angular, PLSQL, Docker Want to learn: Python, Go language, AI, ML and Cloud

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Tachyons in React Native

Hooks in TripCaster

Every React Developer Must Try Out These Best Animation Libraries in React Native

Every React Developer Must Try Out These Best Animation Libraries in React Native

Top 5 tips to boost your WP theme’s performance like Boss

Beginning Javascript Testing — Part 2B:

Simple Web Server with NODE.js

Protect Your REST APIs using JWT.

Building a React Native Music Streaming App from beginning

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vishal Pathak

Vishal Pathak

love ❤ coding, solving some industry problems technologies: JavaScript, C#, Angular, PLSQL, Docker Want to learn: Python, Go language, AI, ML and Cloud

More from Medium

JavaScript Objects

6 Scenarios Where “this” Has Different Values in JavaScript

this keyword in javascript

Arrow Function in JS

Objects in JavaScript