I want to write a function called printNums() that allows for both:
printNums(1, 2, 3)
printNums([1, 2, 3])
In plain JS, the function would look something like:
function printNums(nums) {
if (!Array.isArray(nums)) {
nums = [...arguments]
}
nums.forEach(num => {
console.log(`Num: ${num}`)
})
}
In TypeScript, how would I write/annotate the nums param?