Menu

1 / 2

Understanding Variables and Data Types in JavaScript

DEV Community·Abhishek sahni·6 months ago
#8sgAKfK4
Reading 0:00
15s threshold

In this blog we are going to learn basic fundamentals of programming. We are exploring variables and datatypes in javascript.

First we try to understand variables. So what are variables.

Variables : Variables are containers that stores and manage some data.

There are three ways to declare a variable in javaScript. let , var and const .

syntax to declare a variable :

let variableName = value ;

Enter fullscreen mode

Exit fullscreen mode

var variableName = value ;

Enter fullscreen mode

Exit fullscreen mode

const variableName = value ;

Enter fullscreen mode

Exit fullscreen mode

You can use let , var and const according to your use case.

What is scope : Scope defines where a variable can be access in program.

Global Scope : A variable declared outside any function can be access anywhere in the program.

Function Scope : A variable declared inside a function cannot be accessed outside that function.

Block Scope : Block scope was introduced in ES6.

Variables declared with let and const can only be…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.