Skip to content

Instantly share code, notes, and snippets.

@methodbox
Created July 8, 2019 23:58
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 methodbox/5684433fd3b5c40b5b55c636a5a81c90 to your computer and use it in GitHub Desktop.
Save methodbox/5684433fd3b5c40b5b55c636a5a81c90 to your computer and use it in GitHub Desktop.
typof example
let myNumber = 10;
let myString = 'this is a string';
if (typeof myNumber === 'string') {
console.log('This is a string, not a number.')
} else {
console.log('This is a number');
}
const badMath = (x, y) => {
return x * y;
}
badMath(myNumber, myString) // Output is NaN because myString isn't a number.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment