Detecting Online/Offline Status in Javascript

Learn how to detect if the user is online or offline and handle events if a change in the online/offline state occurs. We can detect if the user is online or offline by using the online property on the navigator object which will return true if the user is connected to the internet, otherwise it returns …

Find the difference between Dates in JavaScript

Learn how to find difference between two dates in JavaScript. Image from Lukas Blazek We learn about finding Number of Seconds , Number of Minutes , Number of hours , Number of days , Number of weeks , Number of months , Number of years between two dates. Let’s create two dates let d1 = Date.now(); let d2 = new Date(2019,5,22).getTime(); //Jun …

Master Destructing Values in JavaScript

Learn how to destructure array and object properties into variables in JavaScript. Image from Unsplash The destructing syntax allows us to extract multiple values based on the property name from objects or arrays. // Destructing arrayvar num = [1,2,3,4,5]; var [a, b] = num; console.log(a, b); //1,2 // Destructing Object var obj = { name : …

Design a site like this with WordPress.com
Get started