Created
April 7, 2021 13:11
-
-
Save DillonMemo/4bbbdad33276381d292f95eff9e3e1e7 to your computer and use it in GitHub Desktop.
Difference javascript and typescript
This file contains 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
/** example */ | |
function addition(a, b) { | |
const result = a + b; | |
return console.log(typeof result, result); | |
} | |
const num1 = 10; | |
const num2 = "20"; | |
addition(num1, num2); // log: string 1020 |
This file contains 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
/** example */ | |
function addition(a: number, b:number) { | |
const result = a + b; | |
return console.log(typeof result, result); | |
} | |
const num1 = 10; | |
const num2 = "20"; | |
addition(num1, num2); // error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment