var bulldogObject = { breed: "English Bulldog", weight: 45, color: "brindle", name: "Rex" }
bulldogObject.weight // returns 45 bulldogObject["weight"] // returns 45 bulldogObject.color // returns "brindle" bulldogObject["color"] // returns "brindle"
// Add a method to the object called 'printInfo' var bulldogObject = { breed: "English Bulldog", weight: 45, color: "brindle", name: "Rex", printInfo: function() {console.log("I am a "+this.breed+" name "+this.name)}} bulldogObject.printInfo()would result in
Value | Description |
---|---|
Infinity | Positive infinity |
NaN | Not a number |
undefined | Undefined variable or function has been called |
null | Empty value without type |
Function | Use | Example | Example Returns |
---|---|---|---|
eval() | Evaluate a JS expression and return as a string NOTE: AVOID THIS FUNCTION | eval(6+5) | '11' |
isFinite() | Returns true if value is finite, false otherwise | isFinite(3.14) | true |
isNaN() | Returns true if value is not a number, false otherwise | isNaN('hello') | false |
parseFloat() | Parses string as a floating point number | parseFloat('3.14') parseFloat('hello') | 3.14 NaN |
parseInt() | Parses string as integer with optional base | parseInt(25,3) parseInt("Hello", 8) | 2 NaN |
Object | Description |
---|---|
String | Wrapper for working with text (see Strings section for more) |
RegExp | Creates regular expression for string pattern matching (see Strings section for more) |
Number | Wrapper for working with numbers (see Math and Numbers section for more) |
Math | Built in object for mathematics (see Math and Numbers section for more) |
Date | Objects based on moment in time, measured in number of milliseconds since 1 January, 1970 UTC. |