/** * @description Check whether the given value is a Date object * @param {any} dateObj – The value to check * @returns {boolean} – True if it’s a valid Date object, otherwise false */ function isInstanceOfDate(dateObj) { return dateObj instanceof Date && !isNaN(dateObj); } console.log(isInstanceOfDate(new Date())); // true console.log(isInstanceOfDate(“2024-02-28”)); // false (string,… Continue reading Checking if an Input is a Date Object
Tag: javascript
JavaScript code to Add/Subtract days from Date Object
let prevPremVal = null; // Initialize previous premium value customrecord_jj_new_commi_report_ahap29SearchObj.run().each(function(result) { let isPremium = result.getValue(result.columns[36]); // Check if it’s premium let tieredPremium = getTieredPremiumValue(result.getValue(result.columns[38]), result.getValue(result.columns[61])); log.debug(“Is Premium:”, isPremium); log.debug(“Tiered Premium:”, tieredPremium); // If isPremium is true and tieredPremium is valid, use tieredPremium //… Continue reading JavaScript code to Add/Subtract days from Date Object
Function for checking valid parameters
function isValid(value) { return value !== null && value !== undefined && value !== “”; }
Allow controlling traverse flow
Make traverse and the rest of the family respect special return values. The most important (in my opinion) would be the ability to ignore the children. For example: // Somewhere in Three.js code. Could be replaced with an enum-style definition const IGNORE_CHILDREN = new Symbol(‘ignore_children’); const HALT_TRAVERSE = new Symbol(‘halt_traverse’); // I didn’t check this… Continue reading Allow controlling traverse flow
20 Advanced JavaScript Tricks for Experienced Developers
Welcome to the world of advanced JavaScript! Whether you’re a seasoned developer looking to sharpen your skills or an enthusiast eager to dive deeper into the intricacies of JavaScript, this blog is designed to inspire and educate. Let’s explore 20 advanced JavaScript tricks that will not only enhance your coding prowess but also bring a… Continue reading 20 Advanced JavaScript Tricks for Experienced Developers
How Async/Await Can Slow Down Your Node.js App
In the world of Node.js, async/await has become a staple for handling asynchronous operations. It’s clean, easy to read, and feels synchronous. But as wonderful as it sounds, misusing async/await can introduce performance bottlenecks that slow down your application. If your app feels sluggish despite using async/await, this post is for you. Why Async/Await Feels Slow Under the hood,… Continue reading How Async/Await Can Slow Down Your Node.js App
How web worker works with a practical example
Ever noticed a webpage freezing during a heavy task? This happens because JavaScript runs on a single thread by default, causing a bad user experience. Users can’t interact and have to wait until the task finishes. This problem can be solved using web workers. In this article, we will discuss what web workers are, why… Continue reading How web worker works with a practical example
The Clean Code Handbook: How to Write Better Code for Agile Software Development
Building scalable software applications requires writing clean code that’s so simple that any dev can understand it. In this article, I’ll explain and demonstrate what clean code is. Then I’ll share my favorite clean code patterns for building modern Agile applications. I won’t use complex jargon. I’ll hit you with simple, clear JavaScript examples that… Continue reading The Clean Code Handbook: How to Write Better Code for Agile Software Development
Clean Code in JavaScript: A Comprehensive Guide 🚀
What is Clean Code? Clean code is code that is: Readable: Easy to understand at a glance Maintainable: Simple to modify and debug Reusable: Can be repurposed for different scenarios Testable: Easy to write unit tests for Scalable: Can grow without becoming complex 1. Variables: The Building Blocks of Clean Code – Use Meaningful Variable… Continue reading Clean Code in JavaScript: A Comprehensive Guide 🚀
Javascript function that makes easier to replace multiple occurrences of a substring.
replaceAll() makes it easier to replace multiple occurrences of a substring. const signal = “Batman! Batman must respond!”; console.log(signal.replaceAll(“Batman”, “Bruce”)); // “Bruce! Bruce must respond!”