1function doSomething(x) {
2 if(typeof(x) === 'string') {
3 alert('x is a string')
4 } else if(typeof(x) === 'number') {
5 alert('x is a number')
6 }
7}
1console.log(typeof "how are you?")
2"string"
3console.log(typeof false) / console.log(typeof true)
4"boolean"
5console.log(typeof 100)
6"number"
1> typeof "foo"
2"string"
3> typeof true
4"boolean"
5> typeof 42
6"number"
7
8if(typeof bar === 'number') {
9 //whatever
10}
1typeof("iAmAString");//This should return 'string'
2//NO camelCase, as it is a JS Keyword