Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typescript wrapping for array

function wrapInArray(obj: string | string[]) {
  if (typeof obj === "string") {
    return [obj];
  }
  return obj;
}
Source by www.typescriptlang.org #
 
PREVIOUS NEXT
Tagged: #typescript #wrapping #array
ADD COMMENT
Topic
Name
3+5 =