Lecture 2 - Introduction To JavaScript
Lecture 2 - Introduction To JavaScript
DEVELOPMENT
Introduction to JavaScript
JavaScript
console.log("a == b:", a == b)
console.log("a === b:", a === b)
JS DataTypes
• Exponential
var x = 10e5
• Object
var person = { firstName:"John", lastName:"Doe", age:50 };
JS typeof Operator
• You can use the JavaScript typeof operator to find the type of a JavaScript
variable.
• The typeof operator returns the type of a variable or an expression:
• Undefined
typeof 3.14 //
typeof true //
Returns
Returns
"number"
"boolean"
typeof false // Returns "boolean"
typeof x // Returns "undefined" (if x has no value)
Complex Data
• The typeof operator returns "object" for objects, arrays, and null.
• The typeof operator does not return "object" for functions.
typeof {name:'John', age:34} // Returns "object"
typeof [1,2,3,4] // Returns "object" (arrays are objects)
typeof null // Returns "object"
typeof function myFunc(){} // Returns "function"
ES6 Variables