Answers for "void in ts"

1

void in ts

// Similar to languages like Java, void is used where there is no data. 
// For example, if a function does not return any value then you can 
// specify void as return type.
function sayHi(): void { 
    console.log('Hi!')
} 

let speech: void = sayHi(); 
console.log(speech); //Output: undefined
Posted by: Guest on January-07-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language