An incoming value might be a single label or an entire list. Check what it is before treating it as either.
typeof reports "object" for an array, so it cannot distinguish an array from other objects. An array is an ordered list written with square brackets, such as [1, 2, 3]. Use typeof for primitive values and Array.isArray() when you need to recognize a list; the Arrays module will explore lists in depth.
const status = "queued";
const route = ["map", "compass"];
console.log(typeof status);
console.log(Array.isArray(route));
messageType to typeof "hello"; the provided probe will log messageType: string.isList with Array.isArray([1, 2, 3]); the provided probe will log isList: true.string | true on a separate line using the two results.Use typeof for primitive values like strings.
Use Array.isArray() when you specifically want to detect an array.