Skip to content

Instantly share code, notes, and snippets.

@haldarmahesh
Last active May 3, 2020 14:32
Show Gist options
  • Save haldarmahesh/e3a5a473b01457291b7d31d1b5144397 to your computer and use it in GitHub Desktop.
Save haldarmahesh/e3a5a473b01457291b7d31d1b5144397 to your computer and use it in GitHub Desktop.
interface Person {
name: String
}
export const convertToValueArray = (value: any): Array<any> => {
return [value];
}
console.log(convertToValueArray(12)); // [12]
console.log(convertToValueArray("STRING")); // ["STRING"}
const person: Person = {
name: "Mahesh"
}
console.log(convertToValueArray(person)); // [ { name: "Mahesh" } ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment