interface User{
fname: string,
lname: string,
mobNumb: number
}
function sendUserDetails<T>(userInput: T[] ): T {
return userInput[0];
}
const userOne = sendUserDetails<User>([{fname:"Donald",lname:"Trumph",mobNumb:7895474474}]);
console.log(userOne.fname);
console.log(userOne.lname);
console.log(userOne.mobNumb);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter