Some interview questions in JavaScript and React

Rizvy Ahamed
4 min readNov 5, 2020

1.What are Closures?

Closure is an internal function with flexible access and external function parameters. Locked everywhere in JavaScript and you may have used it even if you haven’t noticed. But if you use a lock within the render () method, it’s actually bad. Each time a SayHi component is provided, a new anonymous function is performed and transferred to the Button object. Although the props have not changed, the <Button /> button will be forced to reset. As mentioned earlier, used renderings can have a direct impact on performance. Instead, add another closure in the class way. Classroom methods are easy to read and easy to correct.

2. Aware of Stale Closure

The stale closure problem occurs when the closure catches an expired variable. An effective way to solve stale closures is to properly set the dependence of React hooks. Or, in the event of an old situation, use an effective method to restore the state.

Taking the key is trying to give the hooks a new dynamic closure.

3. Semantic HTML

In HTML, for example, the <h1> object is a semantic object, which provides text that wraps the role (or description) of a “high-level title on your page.”
By default, the user agent style sheet in the browser will style <h1> with a larger font size to make it look like a theme (although you can style it to look like anything you want)
On the other hand, you can make anything look like a high-quality theme.

4. Mouse and pointer events

Make sure all functionality displayed with the mouse or pointer event can also be accessed using the keyboard only. Depending on the device it will lead to many situations where keyboard users may not be able to use your app.

To illustrate this, let’s look at an outstanding example of broken access caused by click-through events. This is an out-of-click pattern, where the user can disable the open by clicking on the object.

5. Screen Readers

ChromeVox is a screen reader integrated into Chromebooks and is available as an extension for Google Chrome.

See the following guidelines on how to use ChromeVox:

Google Chromebook Help — Use the built-in Screen Reader
ChromeVox keyboard shortcut reference.

6. What is the difference between null and undefined in JavaScript?

In JavaScript, undefined some sort, and null object.
Undefined:

It means declared flexibility, but no value is given value.
Null:

While, JavaScript is disabled it is a share value. You can assign a variable.

7. What is Triple Equals

Triple equals
When using triple equilibrium === in JavaScript, we check for solid equations. This means that both type and quantity we measure must be the same.
Let’s look at a few examples of solid equity.
In the first example we compare the number 5 with the number 5. As expected, the truth is restored. Both are numbers, and both share the same number 5.

8. What is Double Equals

Double equals
When we use duplicate equations in JavaScript we test loose balance. Double equilibrium also creates genetic compulsion.
Type compulsion means that two values ​​are compared only after attempting to convert them into a standard type.

9. Scope

The scope is not designed that way in JavaScript. To paste a variable x in its width, you will need to address the object of this rating by name or by reference.

What happens in your example is that your call to printX is trying to insert a variable x attached to an external function. functions are found in JavaScript objects, and as a result may have properties attached to them, so instead of giving you a reference error, you get undefined instead, as the variables are non-existent.
As for what you have to do going forward, it really depends on what the ultimate goal was. An easy way to fix this would be, as shown in the comments here, simply to rename the variables. However, that will not solve the big problem of trying to achieve flexibility with a property name instead of a variable name. To access a variable with a name, simply use its name, as opposed to trying to access a property name in this case.

10. How to Remove Duplicate Values from a JavaScript Array.

I can use the indexOf () method by combining Push () to remove duplicate values ​​from the same members or find all values ​​that are different from the same members in JavaScript.
Alternatively, I can use the newly launched ES6 loop instead of the loop to make this filtering easier.

--

--

Rizvy Ahamed

Measuring programming progress by lines of code is like measuring aircraft building progress by weight.