How to Check Type of Data in Javascript
Type of a variable can be checked with 2 Javascript operators - typeof checks for a primitive data type, while instanceof operator checks whether it is a special kind of an object.
How to Convert Values to Numbers in Javascript
While dealing with mathematical calculations we need to make sure that the variable in question is actually a number. Any variable can be converted to a number using the global Number() method.
Checking if All Promises are Completed in Javascript
There are situations where an application needs to wait for the completion of multiple Promises and needs to know when they have all finished. In such cases Promise.all() or Promise.allSettled() methods can be used.
Using Immutable Data Structures In Javascript with Immutable.js
Immutable.js is a library for dealing with immutable data structures in Javascript. With this we can create immutable arrays and objects, and perform operations on them.
Immutable Data Structures In Javascript (VIDEO)
Data immutability becomes important when there are several developers working on a huge web application. This video shows how you can create immutable objects in Javascript.
Checking for Substring in Javascript (ES6 Way)
ES6 has introduced the includes() method which a better way of detecting substring in a given string.
How to Check for a Media Query Match in Javascript
In rare cases we may need to execute some Javascript code depending upon a specific media query. This can be done with the help of window.matchMedia object.
Reading a URL and its Parts with Javascript
Reading a URL and getting information about its various components - hostname, path, parameters etc is one of the common things required in Javascript. This tutorial tells how we can read any url, and get its component parts.
Get and Set CSS Variables with Javascript
In some case we may need to change the value of the CSS variable dynamically, or get the value of the variable in Javascript. This can be done using the native browser APIs.
How to Check if Elements of Array Satisfy a Given Condition (Javascript)
Quite often it is required to know whether elements of an array satisfy a given condition. Instead of using loops we can use native Javascript methods every() and some() to do this.
Passing Custom Parameters to setTimeout Callback
The setTimeout() method can have multiple parameters depending on the need. Custom parameters can be passed after the callback function and timeout parameters. These extra parameters are passed to the callback function - as its arguments.
Web Share API - Implement Share Button on Websites with Native Methods
The Web Share API helps a user in sharing text or URL in a website by using the sharing mechanism of the device. With this API we can add a "Share" button in a website.
Creating Objects with Dynamic Keys in Javascript (ES6 Way)
ES6 has brought in Computed property names that helps in creating a new object with dynamic property names. The dynamic keys are specified between [ ] square brackets.
Javascript Rest Parameter
Rest parameter syntax can be used in function declarations to compress passed arguments to an array. By using the Rest parameter syntax indefinite number of arguments can be passed to a function.
Javascript Spread Operator
Spread operator will expand an iterable, such as an array or a string. Expansion here means that the input object is broken down to its individual values.
How to Read Local Files with Javascript
There are some cases where a web application needs to read a local file from the user's system. This can be done with the FileReader interface.
Merging of Arrays in JavaScript
The concat() method can be used to merge two or more arrays. Duplicates in the merged array can be removed using a Set object.
Extracting a Part of an Array in JavaScript
A part of an array can be extracted with the Array.slice() method.
Getting Browser Window Size with JavaScript
JavaScript has built-in methods which returns the browser window dimensions. We can also listen to an event to track resizing of the browser window.
Intersection and Difference of Arrays in JavaScript
The filter() method can be used to get intersection or difference of arrays. Duplicates can be eliminated by converting array to a Set object.