Fading Coder

One Final Commit for the Last Sprint

JavaScript Deep Copy Implementation Guide for Interview Assessments

Shallow vs Deep Copy Shallow copy creates a new object with an exact duplicate of the original object's top-level property values. For primitive type porperties, the actual value is copied, while for reference type properties, only the memory pointer is copied. Modifying nested reference values in t...

Asynchronous Control Flow in JavaScript

In single-threaded JavaScript, asynchronous execution is managed via callback functions. Consider how operating systems handle interrupts: while a peripheral device completes I/O, the CPU continues other work until an interrupt signals completion. Callbacks operate on a similar principle—the runtime...

Advanced JavaScript: Object Construction and Built-in Constructors

Object Construction Constructor Functions A constructor function serves as a blueprint for creating objects. <script> // Constructor function - note the capitalized first letter function User(name, age, hobby) { this.name = name; this.age = age; } // Instantiating an object using the new keywo...

Essential JavaScript Built-in Constructors and Methods

Reference Type Constructors Object Constructor The Object constructor creates generic objects. Several useful static methods are available: Object.keys(object): Retrieves all enumerable property names (keys) from the object. Returns an array of strings. Object.values(object): Retrieves all enumerabl...

Using Promises in JavaScript: Methods and Concurrency Control

Using Promises in JavaScript: Methods and Concurrency Control
1. Promise Methods Overview Promise.resolve Wraps a value into a resolved promise. Promise.resolve('hello').then(s => console.log(s)); Promise.reject Wraps a value into a rejected promise. Promise.reject(reason).catch(e => console.log(e)); Promise.all Waits for all promises to resolve. Rejects...

Essential JavaScript Array Methods for Data Manipulation

Finding Element Posiitons The indexOf() method locates the first occurrence of a specified value within an array and returns its position: const sequence = [1, 2, 3, 4, 5, 6, 7, 8, 9]; const position = sequence.indexOf(7); console.log(position); // Output: 6 Combining Arrays Arrays can be merged usi...

JavaScript's Object Creation Fundamentals

JavaScript's Object Creation FundamentalsIn JavaScript, every object is instantiated through a function constructor, even when using literal syntax.Function Constructors and Object CreationConsider the following example of creating an object using a function constructor:function Person(name, birthYe...

Common Objects in JavaScript

JavaScript is an object - based scripting language. It has classes and objects, but it doesn't strictly implement encapsulation, inheritance, or polymorphism like traditoinal object - oriented programming languages. Browsers natively support several built - in objects, such as Array, String, Math, N...

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...