Introduction
In this blog, I am going to discuss some important and basic key concepts of JavaScript.
Let’s see them one by one;
In JavaScript we declare variables using var keyword; we may assign the variable or we may not.
Key Capsule 1
So what happens when we declared var name;
Capsule 1
Here name stores undefined by default;
iI we print using console.log(name)
o/p - undefined.
Key Capsule 2
- var name=”Surya”
- var name;
- console.log(name) What you think what will be the out put ?
O/P - “Surya”
Capsule 2
In javascript, although I declare the variable once again it won’t lose the value.
Key Capsule 3
- var result=”sun”+2+3;
- console.log(result)
- result=2+3+”sun”;
- console.log(result)
What you think the output is?
O/P - “sun”23
5”sun”
Capsule 3
In javascript, if any numeric values come after the string then the Plus (+) operator works as a concatenation operator whereas if the numeric value comes before the string then plus (+) operator works and it shows the addition of number then it concatenates the string.
Key Capsule 4
- var studnetName=”Suryakant”;
- var studentName=”Rajanikant” ;
- console.log(studentName);
- var studnetName=”Rahul”;
- var studentname=”Raj”;
- console.log(studnetName);
- console.log(studentname);
What will be the output?
O/P - “Rajanikant”
“Rahul”
“Raj”
Capsule 5
Why so? Because the JavaScript variables are case sensitive; so when I write studnetName and studnetname both are different variables.
Remember all variables in JavaScript are called identifiers and each variable is a unique identifier.
Key Capsule 6
How to print a string like this,
“The name is “Surykant”; he is a blogger.”
I want to print suryakant with the double-quotes.
To do this in javascript we have different escape characters that can be used to achieve this.
We can write,
var data=”The name is \”Suryakant\”; he is a blogger”.
Same for a single quote,
var data=”It\’s looking good.”
Most Important Key Capsule 7
Difference between == and === operator
“== “ operator is used to checking directly the value whereas “===” equality operator checks the equality and types.
See below examples;
Test Case 1
var x=”surya”;
var y= “surya”;
console.log(x==y)
console.log(x===y)
o/p- true
Note
Here the output is true for both cases because both are storing the same value and both are of the same type
Test Case 2
var x=”surya”
var y=new string (“surya”)
console.log(x==y);
o/p- true
Scenario
Here some of us might wonder why it returns true.
This question also came to my mind; because the second one is reference type; as we know inside the reference type variable it stores the address of that value i.e “surya”.
So how are both equal then?
Here the important thing to understand is what actually happens when we comparing the value using a double equality operator (“==”).

Join the conversation! Your thoughts help the community grow.