Complete the code to check if a variable is a string at runtime.
function isString(value: unknown): boolean {
return typeof value === [1];
}Use typeof value === "string" to check if the value is a string at runtime.
Complete the code to check if a value is an array at runtime.
function isArray(value: unknown): boolean {
return Array.[1](value);
}Array.of or Array.from which create arrays but don't check types.isObject.Use Array.isArray(value) to check if the value is an array at runtime.
Fix the error in the code to check if a value is a number at runtime.
function isNumber(value: unknown): boolean {
return typeof value === [1];
}number without quotes causes a syntax error.Number object instead of the string type name.The typeof operator returns a string, so the type must be in quotes like "number".
Fill both blanks to create a runtime check for an object that is not null.
function isObject(value: unknown): boolean {
return typeof value === [1] && value !== [2];
}value !== "null" instead of null.null and getting false positives.Check that typeof value === "object" and that value !== null because null is also of type "object" in JavaScript.
Fill all three blanks to create a runtime check for a string array.
function isStringArray(value: unknown): boolean {
return Array.[1](value) && value.every(item => typeof item === [2] && item !== [3]);
}typeof item === 'object' instead of 'string'.null values inside the array.Use Array.isArray(value) to check if it's an array, then check every item is a string and not null.