In this tutorial, we see the hidden gem that is Detecting device orientation in Web Using Javascript. you need to make sure your browser supports it. You can easily check caniuse.com. Code & Demo Works Better in Mobile Detecting device orientation It allows a device to detect its physical orientation with respect to gravity. If […]
You can use this approach via passing the data as an internal object, filed to be updated, and value of the field. nestedObjectGetUpdate(data, field, value) { let schema = data; // a moving reference to internal objects within obj const pList = field.split(‘.’); const len = pList.length; for (var i = 0; i < len […]
Can anyone have a better solution to get and update nested object values with the dot notation string using javascript? I have an object say, let user = { “fullname”: { “firstname”: “abc” “lastname”: “xyz” } }; and I have a string with the dot notation which indicates what key needs to get or updated […]
Async allows execution of scripts asynchronously and defer allows execution only after the whole document has been parsed. With async, the file gets downloaded asynchronously and then executed as soon as itβs downloaded. With defer, the file gets downloaded asynchronously but executed only when the document parsing is completed. Just note this will not affect […]
What is the difference between async and defer in JavaScript? While we import the javascript file using script tag we use async or defer or just normal script tags what is the difference. // Normal Include <script src=”demo.js”></script> // Defer Include <script src=”demo.js” defer></script> // Async Include <script src=”demo.js” async></script>
For Merging two different object you can do this /** * Merge Two objects and return combined object */ merge = (target, source) => { // Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties for (const key of Object.keys(source)) { if (source[key] instanceof Object) { if […]
What is the best way to merge two object and return a combined one using javascript?
In this tutorial, we will see the different methods for To Add and Remove CSS Class Using Javascript by taking the reference of the element ID. Add or Appending CSS Class Using Javascript There are two possible ways to add or append the CSS class to the HTML element i.e via className and classList CSS […]
In this tutorial, we will see how to use import and export in javascript. Due to one of the best features of the ES6 is the ability to import and export the javascript module. Before the ES6 we used to import module using require() function. Export in Javascript There are two different types of export […]
What Is Async-Await In Javascript really means? As the name suggests when there is an async that means u need to wait. Why Do We Need To Wait? because javascript is non-blocking, by default it doesn’t wait for something to be executed. { // new situation console.log(“we should go in !”); // some msg console.log(“friend: […]