Created
June 27, 2018 18:13
-
-
Save maxencefrenette/3595319a6c372214af65ad6f9d77804b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Cat { | |
readonly name: string | undefined; | |
} | |
function catPrinter(cat: Cat) { | |
if (cat.name === undefined) { | |
return; | |
} | |
console.log(cat.name.trim()); | |
} | |
function delayedCatPrinter(cat: Cat) { | |
const cat2 = cat; | |
if (cat2.name === undefined) { | |
return; | |
} | |
setTimeout(() => console.log(cat2.name.trim()), 100); | |
// ... | |
} | |
function delayedPrinter(cat: string | undefined) { | |
const cat2 = cat; | |
if (cat2 === undefined) { | |
return; | |
} | |
setTimeout(() => console.log(cat2.trim()), 100); | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment