JavaScript Declare VS Assign
There’s a difference between declaring/creating a variable and assigning a value to it using the assignment operator.
Declare / Create a variable in JavaScript
So if we have something like this:
let myNum; // undefinedHere, we are creating/declaring a variable but it has no value in it. Thus it’s undefined. (undefined is a data type in JavaScript. we’ll cover in the next few videos)
Get Firdavsi Web Dev’s stories in your inbox
Join Medium for free to get updates from this writer.
Assign/ Set a value to the variable above
myNum = 20; // result or value is 20Here we used = sign to set/assign the value 20 to variable called myNum
You can also declare and assign to an initial value at the same line. Like so:
// Create And Assign value at the same line
let myAge = 29; Thanks for reading. Follow me for more JavaScript & Programming Tutorials.







