| by Gagandeep Singh | No comments

undefined and null in Javascript

undefined In Javascript undefined (a primitive type in Javascript) gets assigned to a variable that we declare but don’t assign a value to. It’s Javascript’s way of telling that the value of this variable is not defined. Even a function in Javascript which does not return anything, will return undefined by default. So, to avoid […]

Read More
| by Gagandeep Singh | No comments

Using useState hook with the previous state

Let’s take a very basic use case of the useState() hook; updating the count variable on each click. The code look perfectly fine and will work as expected in almost every time. BUT the issue with this code is that setCount() doesn’t guarantee that the previous count that it’s going to use to either increment […]

Read More
| by Gagandeep Singh | No comments

Browser storage (overview)

Storing data on the machine of the user Data is available to the user on that particular machine and hence cannot be shared with anyone else Example: Storing data such as items in my shopping cart or recently viewed products Different types of browser storage options available are: Local storage / Session storage Cookies IndexedDB […]

Read More
| by Gagandeep Singh | No comments

Understanding ReactJS Hooks

React Hooks have been added to React library from version 16.8 and they provide the functionality to use state and few other features inside the functional component without creating React class.  useState The first hook is useState. This let us define a state inside a functional component. useState() returns the current state and a function […]

Read More
| by Gagandeep Singh | No comments

ES7 features you should be using.

Array includes() method The old way to check if some value is present inside an array was to use Array’s indexOf() method. IndexOf() returned -1 if element is not found or else the position of element if it’s present in the array. Exponential operator Similar to Math.pow(), the exponential operator ** was introduced in ES2016. […]

Read More