10 important things that you need to know about JavaScript.

Al Mahamud Murad
4 min readMay 8, 2021

Interview Question

Hello, JavaScript developer what’s up? Today in this article we discuss some important js interview questions, that can help you in your interview.

1. Use Only One Method to create, read, update and delete Elements in Array.

I think you are thinking about this how can I do this. it is a very simple javascript that gives us an awesome method to do this.

This is array.splice() method

The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.

Now we show how to do this with one method.

  1. Create an element in the array:

here names.lenght refer the last index of a array

2.Read a new array :

without delete operation, newNames return an empty array.

when the delete operation execute then it returns a deleted element in a new array

3.Delete element:

Here we the delete element shows in the new array.

4.Update an element:

At least we show that how the splice operator works.

2.Null vs Undefined

undefined: undefined means the value of the variable has not been assigned or for any function, if there is no return value then the function returned “undefined”. Because javascript variables start with undefined if they are not initialized or defined.

Null: null means the variable has no value and that is known by the programmer and also value is assigned as ‘’null’ by the programmer.

Undefined
Null

3. Private variable in Javascript:

Private variable in javascript is an OOP(Object-oriented programming concepts). This means which variable we declare as a private variable it can’t be accessible in other classes. It is only accessible in its parent class.

4.Window object in Javascript:

The window object in javascript represents the global object in browsers. Global variables are properties of the window object. There are many types of the global variable exists. look at the below images.

Global window object in javascript

5.What is DRY:

If we can live in good health we need clean and calm food, an environment, and so on. In the same way, if our code should be clean and clean so that everyone understands the code. The DRY principle helps us to keep this type of code. DRY means Do not Repeat Yourselves. That means we write one type of code one time. Not again and again we repeat the same code.

6.IIFE:

Generally, when we create a function for any reason it should be called for the execution of the function. What if when we create the function and immediately call this? That is the concept of IIFE. IIFE means Immediately Invoked Function Expressions. We create a function and call the function in the same function code.

7.Double equal vs triple equal:

The most important thing when we compare two values is equal or not equal this time we use == or ===. Both of them return a true or false value.

  1. == (Double equals operator): Known as the equality or abstract comparison operator. Double equal doesn’t concern about the type it is concern about value.

2.=== (Triple equals operator): Known as the identity or strict comparison operator. If two value has the same type then it returns true otherwise false.

8.Object Destructuring

Object destructuring is a new way to extract elements from an object or an array.

Object destructuring:

As one can see, using object destructuring we have extracted all the elements inside an object in one line of code.

9.Arrow functions

Arrow functions were introduced in the ES6 version of javascript. They provide us with a new and shorter syntax for declaring functions. Arrow functions can only be used as a function expression.

Let’s compare the normal function declaration and the arrow function declaration in detail.

Arrow functions are declared without the function keyword. If there is only one returning expression then we don’t need to use the return keyword as well in an arrow function as shown in the example above. Also, for functions having just one line of code, curly braces { } can be omitted.

If the function takes in only one argument, then the parenthesis () around the parameter can be omitted as shown in the code above.

10.Differences between declaring variables using var, let, and const.

Before the ES6 version of javascript, only the keyword var was used to declare variables.

With the ES6 Version, keywords let and const were introduced to declare variables.

That’s for today.

Happy Coding…..

--

--