Fading Coder

One Final Commit for the Last Sprint

JavaScript Event Binding Methods and Implementation

Direct Assignment Binding (DOM Level 0) const element = document.querySelector('.target'); // Assign event handler directly element.onclick = function() { console.log('First handler'); }; // Overwrites previous handler element.onclick = function() { console.log('Second handler'); }; // Remove event...

Building a Custom Promise.all from Scratch

How Promise.all Works Promise.all takes an array of Promise instances and returns a new Promise. When all input promises resolve successfully, the returned promise resolves with an array of results in the same order as the inputs. If any single promise rejects, the entire operation fails immediately...

Strategies for Removing Duplicate Entries in JavaScript Arrays

Removing duplicate values from collections is a frequent requirement in data processing. Different language constructs handle identity comparisons and structural immutability differently, particularly regarding edge cases like NaN. 1. Native Set Construction The Set data structure inherently enforce...

Chaining Promises for Sequential Asynchronous Tasks

The then() method of a Promise returns a new Promise, enabling you to connect multiple asynchronous operations without deeply nested callbacks. What ever you return in side a then() callback determines the state and result of the subsequent Promise in the chain. The first example uses setTimeout to...

Customizing jQuery EasyUI DateBox for Granular Year-Month Selection and Period-Driven Formatting

The following implementation demonstrates how to restrict the jQuery EasyUI datebox component to year-month granularity while dynamically adjusting its display behavior based on an external period selector. Additionally, a lightweight alternative using combobox is provided for single-year selection...

Implementing Inheritance in JavaScript Using Prototype Chains

In object-oriented programming, inheritance allows new types to acquire properties and methods from existing ones. JavaScript supports implementation inheritance primari through prototype chains, as it lacks interface inheritance due to functions not having signatures. Prototype Chain Mechanism A pr...

Implementing Debounce and Throttle for JavaScript Performance Optimization

Debouncing and Throttling High-frequency event triggers, such as scrolling or rapid clicks, can lead to excessive execution of event handlers, wasting browser resources. These techniques manage execution frequency to improve performance. Debouncing limits execution to a single occurrence, either the...

Implementing the Promises/A+ Specification from Scratch in JavaScript

A Promise implementation begins as a class. The constructor receives a callback, commonly referred to as the executor, which runs immediately with two functional parameters: resolve and reject. class MyPromise { constructor(executor) { const resolve = () => {}; const reject = () => {}; executo...

Mastering jQuery Mobile Configuration, Events, and Navigation APIs

jQuery Mobile initializes its framework components immediately after the DOM is ready. To override default behaviors, developers must intercept the mobileinit event before the core library loads. This event serves as the central hook for customizing global settings, CSS class mappings, and navigasio...

Understanding and Applying JavaScript Promises for Asynchronous Operations

A Promise is a built-in JavaScript object introduced in ECMAScript 2015 that represents the eventual outcome of an asynchronous operation — either a resolved value or a reason for rejection. Each Promise instance transitions through exactly one of three mutually exclusive states: Pending: The initia...