Three important Concepts in JavaScript

chamindu jayasith
Feb 23 · 3 min read

We all know JavaScript is one of the fastest grooving and most popular language. JavaScript is like any other programming language that you are learning in life. There is a lot of an important lot of concept in JavaScript. If you are a JavaScript developer, then you need to know these three concepts.

  1. Hoisting
  2. Scope
  3. Equality

Hoisting

In the above code, I called Printname function before function declaration, but I get output in the console because of hoisting. what hosting does is when we compile the code, the compiler hoisted all declaration to the top of their scope. Hoisting does not mean all declaration are physically move to the top of their scope. What happen is before executing your code, the compiler goes through top to bottom in your code and creates a space in memory for all declaration in code. After complete the compilation, your code start execute.

Scope

  1. Global scope
  2. Local scope

Global scope

In above code variable called age in a global scope because it declared at the root of the script. That age variable can use both inside and outside a function in this script.

Local scope

In above code variable called age in local scope because it declared in the inside of a function. We cannot access a local variable from the outside of a function. If we try to access that local variable from the outside of a function, we will get an error as an output like in above.

Equality

JavaScript has two separate operators that check for equality. One is double equal which is a test for abstract equality and the other one is triple equal which tests for restrict equality. The deferent is abstract equality does not check data type it checks the only value of each variable other hand restrict equality check both value and data type of each variable. When we check the object, which had the same named objects with the same assigned value we get the result as a false. when two objects check by an equal operator what happens is it check only both objects memory addresses are equal or not. That why got output as a false for both equality operators in above. When we create an object, it generates a new memory address.

In this article, I briefly explain three important concepts in JavaScript. If you are interested or want to learn more about this kind of JavaScript concepts you can refer below links.

15 javascript concepts that every javascript programmer must know.

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data…

Sign up for Analytics Vidhya News Bytes

By Analytics Vidhya

Latest news from Analytics Vidhya on our Hackathons and some of our best articles! Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

chamindu jayasith

Written by

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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