Skip to content

Instantly share code, notes, and snippets.

@DillonMemo
Created April 7, 2021 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DillonMemo/4bbbdad33276381d292f95eff9e3e1e7 to your computer and use it in GitHub Desktop.
Save DillonMemo/4bbbdad33276381d292f95eff9e3e1e7 to your computer and use it in GitHub Desktop.
Difference javascript and typescript
/** 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
/** 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