Accessing an Object’s Keys, Values, and Entries in JavaScript

Let’s dive into objects Photo by Matt Artz on Unsplash Object.keys(obj) → returns an array of a given object’s property names. Object.values(obj) → returns an array of a given object’s own property values. Object.entries(obj) → returns an array of a given object’s own string-keyed property [key, value] pairs. var user = { name : “John”, profession : …

Redirect, Refresh, and Access the URL of the Current Page in JavaScript

JavaScript’s location object Photo by Javier Allegue Barros on Unsplash We can use the window.location property to access the URL of the current page and modify it. let location = window.location; For redirecting the page we can use: location.href = “new url”; // or we can use location.assign(“new url”); For redirecting without storing in history: location.replace(“new url”); …

Using the every() and some() methods of Array in JavaScript

Learn how to use every and some method in JavaScript. every → Checks if all elements of the array satisfies the provided callback function some → Checks if any one of element in the array satisfies the provided callback function every The every method will take a testing function as an argument, all the element …

Design a site like this with WordPress.com
Get started