Fading Coder

One Final Commit for the Last Sprint

TypeScript Utility Functions for Runtime Type Checks

Core Type Matching Function const typeString = Object.prototype.toString; export function matchesType(input: unknown, expectedType: string): boolean { return typeString.call(input) === `[object ${expectedType}]`; } Check if Defined export function isDefined<T = unknown>(value?: T): value is T...

Pitfalls of Legacy Array Detection in JavaScript and the Safe Alternative

Why Object.prototype.toString.call Fails In typical scenarios, Object.prototype.toString.call returns a string that reveals the internal type: const items = [10, 20, 30]; const record = {}; console.log(Object.prototype.toString.call(items)); // [object Array] console.log(Object.prototype.toString.ca...