10 JavaScript concepts that every JavaScript Programmer must know.

This post covers some basic concepts in JavaScript. Every JavaScript programmer must know and master these.

1. understanding Scope:

The scope is the accessibility of variables, functions, and objects in some particular part of your code during runtime. In other words, scope determines the visibility of variables and other resources in areas of your code.

the scope is defined in the main two ways,

  • Global Scope
  • Local Scope

consider above code greeting variable should be global scope, it can access inside the function,

In the above code for local scope,

In scope level variables in JavaScript ES6 has updated hoisting variable let, var, const type check with that, In order to learn the scope, you need to understand hoisting also.

2. JavaScript Closures:

A closure is the combination of a function and the lexical environment within which that function was declared.

Let see a closure example below:

In this code, We have an outer function User() which returns an inner function as displayName (),

The inner function will have access to the variables in the outer function scope, even after the outer function has returned.


IIFE (Immediately Invoked Function Expression) is a JavaScript function that runs as soon as it is defined.

Use cases :

Because our application could include many functions and global variables from different source files, it’s important to limit the number of global variables. If we have some initiation code that we don’t need to use again, we could use the IIFE pattern. As we will not reuse the code again, using IIFE, in this case, is better than using a function declaration or a function expression.

4. Variables:

Variable Declaration: Here the variable is registered in its corresponding scope, the scope of a variable is simply “where the variable can be used.” We’ll be talking more about scope in the next lesson.

These are examples of variable declarations:

  1. Variable Initialization: This usually occurs when a variable is declared. Here the variable is assigned a memory or space by the JavaScript engine. Because of this, once a variable is declared, it takes a value of undefined even before the assignment.
  2. Variable Assignment: Variable assignment is usually the most important step when using a variable. Here the variable is assigned data which is a value using the assignment operator “=”. Values in JavaScript take one of the standard JavaScript datatypes which are:
  3. String





8.Any of the complex data structures (Array and Objects)

5. IndexOf():

This method returns -1 if the value to search for never occurs.

6.Array slice() Method :

The slice() method selects the elements starting at the given start argument, and ends at, but does not include, the given end argument.

Note: The original array will not be changed.

7.Array slice() Method :

If an empty string (“ “) is used as the separator, the string is split between each character.

The split() method does not change the original string.


The reduce () method executes a provided function for each value of the array (from left to right).

The return value of the function is stored in an accumulator (result/total).

9.replace() :

10.map() :

The map() method calls the provided function once for each element in an array, in order.

map() does not execute the function for array elements without values.

this method does not change the original array.

I am a front-end developer. I love to know about new technologies.