Top 10 Basic JavaScript Interview Topics with ReactJS

Md. Sakif Uddin Khan
3 min readNov 7, 2020

What are Closures?

Closures are one of many basic concepts in JS. Though it is one of the fundamental concepts, it is very much confusing to many new developers.

The closure is when a function is able to remember and access its lexical scope even when that function is executing outside its lexical scope.

Accessibility:

Web accessibility means the designing and creation of the website can be used by everyone. This support is mandatory to allow helper technology to interpret websites to people with special need.

React fully supports building accessible websites, often by using standard HTML techniques.

Truthy & Falsy Values:

By default some values in JavaScript has truth or false values. Any number except Zero is considered to be a truth value in JS, and Zero is considered to be False automatically.

Again string with some value is truth and an empty string is considered to be falsy.

React Hooks:

Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class.

Hooks have been introduced from the 16.8 version of react. It makes it ier to use state and other different features without writing a new class.

import React, { useState } from 'react';function Example() {
// Declare a new state variable, which we'll call "count" const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>
Click me
</button>
</div>
);
}

This new function useState is the first “Hook”.

Rules of Hooks:

There are some basic rules of using hooks. They are:

  1. Only calling hooks at the top level.
  2. Only calling hooks from React Functions.

NULL VS Undefined:

If a function does not explicitly return anything then it is called Undefined. Again if we do not assign any value to a variable, it is called undefined. Undefined is negative or falsy.

NULL means non-existent, developers usually set this value, after taking out all the values from a place.

Double Equal (==) Vs Triple Equal (===)

There arise some confusion regarding this == and === in JS. == just checks the value on both sides, if the value are the, then it returns true. === checks both the value and the type of data provided on both sides. If they are the and exact, then it returns true. Otherwise, t returns false.

Scope, Block Scope, Access outer Scope Variable:

Scope means the area where we can use a declared variable. For example, if we think about a function, if we declare a variable using let/constant inside this function, we can not use this variable outside the area of this function. This is called scope.

And when declaring a variable, if we use “var”, it hoists the variable from the block scope and we can use the variable anywhere in the parent scope.

--

--

Md. Sakif Uddin Khan
0 Followers

I am a self taught "Web Developer" specailizing in Front End Web Development.