In how many ways can you create an array in JS?

Posted by Jessica Taylor | Updated on | JavaScript interview


There are three different ways of creating an array in JavaScript, namely: By creating instance of an array: var someArray = new Array(); By using an array constructor: var someArray = new Array(‘value1’, ‘value2’,…, ‘valueN’); …

Can you differentiate between let and var?

Posted by Jessica Taylor | Updated on | JavaScript interview


Both let and var are used for variable and method declaration in JavaScript. However, the most important difference between the two JS keywords is that while the var keyword is function scoped, the let keyword …

Could you enumerate the various features of JavaScript?

Posted by Jessica Taylor | Updated on | JavaScript interview


Some important features of JavaScript are: A lightweight interpreted a programming language with some object-oriented capabilities An open, cross-platform scripting language Complements and integrates with the Java programming language as well as other backend technologies. Designed especially …

Please explain the various JavaScript data types?

Posted by Jessica Taylor | Updated on | JavaScript interview


There are a total of 7 basic data types supported by JavaScript. Each one of them is briefed up as follows: Boolean – Represents true and false values Null – Represents empty, nothing, and unknown type of …

Please describe the most important advantages of using JavaScript?

Posted by Jessica Taylor | Updated on | JavaScript


There are several advantages to using JavaScript. Most notable amongst them are listed down as follows: Enhanced interactivity – JavaScript allows creating interfaces that react when the user activates them via the keyboard or merely hovers …

What does setState do?

Posted by Jessica Taylor | Updated on | Reactjs


setState() schedules an update to a component’s state object. When state changes, the component responds by re-rendering.

Where in the component lifecycle should I make an AJAX call?

Posted by Jessica Taylor | Updated on | Reactjs


You should populate data with AJAX calls in the componentDidMount lifecycle method. This is so you can use setState to update your component when the data is retrieved.

How can I make an AJAX call?

Posted by Jessica Taylor | Updated on | Reactjs


You can use any AJAX library you like with React. Some popular ones are Axios, jQuery AJAX, and the browser built-in window.fetch.

How does React associate Hook calls with components?

Posted by Jessica Taylor | Updated on | Reactjs


React keeps track of the currently rendering component. Thanks to the Rules of Hooks, we know that Hooks are only called from React components (or custom Hooks — which are also only called from React components). …

Do Hooks work with static typing?

Posted by Jessica Taylor | Updated on | Reactjs


Hooks were designed with static typing in mind. Because they’re functions, they are easier to type correctly than patterns like higher-order components. The latest Flow and TypeScript React definitions include support for React Hooks. Importantly, …

Do Hooks replace render props and higher-order components?

Posted by Jessica Taylor | Updated on | Reactjs


Often, render props and higher-order components render only a single child. We think Hooks are a simpler way to serve this use case. There is still a place for both patterns (for example, a virtual …

Do Hooks cover all use cases for classes?

Posted by Jessica Taylor | Updated on | Reactjs


Our goal is for Hooks to cover all use cases for classes as soon as possible. There are no Hook equivalents to the uncommon getSnapshotBeforeUpdate, getDerivedStateFromError and componentDidCatch lifecycles yet, but we plan to add them soon. It is an …

How much of my React knowledge stays relevant?

Posted by Jessica Taylor | Updated on | Reactjs


Hooks are a more direct way to use the React features you already know — such as state, lifecycle, context, and refs. They don’t fundamentally change how React works, and your knowledge of components, props, …

What can I do with Hooks that I couldn’t with classes?

Posted by Jessica Taylor | Updated on | Reactjs


Hooks offer a powerful and expressive new way to reuse functionality between components. “Building Your Own Hooks” provides a glimpse of what’s possible. This article by a React core team member dives deeper into the new capabilities unlocked by …

Do I need to rewrite all my class components?

Posted by Jessica Taylor | Updated on | Reactjs


No. There are no plans to remove classes from React — we all need to keep shipping products and can’t afford rewrites. We recommend trying Hooks in new code.