When developing a Node.js application using Express.js, structuring your codebase effectively is crucial for maintainability, scalability, and ease of collaboration. A well-organized project structure allows you to manage complexity, making it easier to navigate and understand the code. In this blog, we’ll explore a typical folder structure for an Express.js application and explain the purpose… Continue reading How to Structure Your Backend Code in Node.js (Express.js)
Category: JavaScript
JavaScript Event Loop: A Deep Dive
JavaScript, being a single-threaded language, executes one task at a time. However, it handles asynchronous operations with ease, thanks to the event loop. The event loop is a fundamental concept that powers JavaScript’s concurrency model, allowing it to manage multiple operations efficiently without blocking the main thread. In this article, we’ll explore the intricacies of… Continue reading JavaScript Event Loop: A Deep Dive
Hiding a Sublist Using Inline HTML Method
In NetSuite, hiding specific elements on a form can be achieved by injecting custom HTML or JavaScript into the page. The provided code demonstrates how to hide a sublist (in this case, a subtab) on a NetSuite form using the INLINEHTML field type. Here is a breakdown of how the code works: 1. Creating an… Continue reading Hiding a Sublist Using Inline HTML Method
Changes to the url.resolveScript(options) SuiteScript method
What is changing? As of September 30, 2024, the return of external URLs with url.resolveScript(options) will be allowed only for authenticated sessions. Scripts that use url.resolveScript(options) with the returnExternalUrl parameter set to true will no longer work in untrusted contexts. To avoid errors, you must review scripts that use the url.resolveScript(options) method with the returnExternalUrl parameter set to true and ensure that this setting is used only in a trusted… Continue reading Changes to the url.resolveScript(options) SuiteScript method
Object.entries and Object.fromEntries in JavaScript
Object.entries It takes an object and returns an array of that object’s own enumerable string-keyed property [key, value] pairs. const person = { name: ‘Bruce’, age: 30, job: ‘Engineer’ }; const entries = Object.entries(person); console.log(entries); // Output: [[‘name’, ‘Bruce’], [‘age’, 30], [‘job’, ‘Engineer’]] Object.fromEntries Does the reverse of Object.entries.… Continue reading Object.entries and Object.fromEntries in JavaScript
reduce and reduceRight in JavaScript
reduce processes the array from left to right (starting from the first element and ending with the last element). const arr = [‘a’, ‘b’, ‘c’, ‘d’]; const result = arr.reduce((acc, curr) => acc + curr, ”); console.log(result); // Output: “abcd” reduceRight processes the array from right to left (starting from the last element and ending… Continue reading reduce and reduceRight in JavaScript
Expanding Array of Objects Based on a Specified Quantity
In some scenarios, you might have an array of objects representing items in an order or list. Each item might have a quantity or count, and you need to expand this array so that each item appears multiple times based on its quantity. // Sample array of objects representing order line details let orderLineDetails =… Continue reading Expanding Array of Objects Based on a Specified Quantity
Debunking Common NodeJS Misconceptions
Some misconceptions Nodejs is single threaded: Yes and No. Yes when you think of Event loop, V8 and No when you’re think of a thread pool.. The javascript code i.e. execution context is single threaded. So if you block by running some js intensive operation it might block the event loop. Nodejs used thread pool for… Continue reading Debunking Common NodeJS Misconceptions
Async IO in NodeJS
Deep dive in Nodejs Internals (Blocking, Non-blocking IO, select/poll/epoll, event loop) We all know by now that Nodejs scales, but why & how? is the question asked by many to no satisfactory answer as there is a lack of satisfactory answers as most of the content available online does not cover the internal workings and provides… Continue reading Async IO in NodeJS
Clustering and PM2: Multitasking in NodeJS
Deep Dive in Cluster and PM2 What & Why is Clustering was needed? We are well aware that NodeJS is not specifically built for CPU-intensive tasks because of its single-threaded architecture. However, this doesn’t mean that we can’t make use of it for such tasks. In fact, NodeJS offers a couple of options to handle… Continue reading Clustering and PM2: Multitasking in NodeJS