Public · Protected · Private
Javascript
Type: Public  |  Created: 2010-07-11  |  Frozen: Yes
« Previous Public Blog Next Public Blog »
Comments
  • Special Characters \' Single quote (‘) \" Double quote (“) \\ Backslash (\) \b Backspace \t Horizontal tab \n New line character \r Carriage return character \f Form feed character \ddd Octal sequence (3 digits) \xdd Hexadecimal sequence (2 hex digits) \udddd Unicode sequence (4 hex digits)
    2010-07-11 04:40
  • Two ways to create objects var myCar = new Object(); var myCar2 = { }; Object Properties var myCar = new Object(); myCar.make = 'Ford'; myCar.model = 'Explorer'; var myCar2 = { make: "Ford", model: "Explorer" }; Object Properties as Associative Arrays var myCar = new Object(); myCar.make = 'Ford'; myCar["model"] = 'Explorer'; alert (myCar.make === myCar["make"]); // alerts true. Because objects store their properties in an associative array, we can iterate over the properties using a for...in loop. var myCar = new Object(); myCar.make = 'Ford'; myCar["model"] = 'Explorer'; myCar.year = 2003; myCar.mileage = 60000; var propValues; for (var propName in myCar) { propValues = propValues + " " + myCar[propName]; } alert (propValues); / alerts "Ford Explorer 2003 60000 ";
    2010-07-11 04:50
  • var myOtherCar = { make: "Ford", model: "Explorer", year: 2003, mileage: 60000 print: function() { alert (this.make + " " + this.model); } } myOtherCar.print // alerts 'Ford Explorer' //to remove.. myCar.print = null; // to really delete delete myCar.print;
    2010-07-11 04:58
  • var x = new Number(); if (x.constructor === Number) { alert ("x is a number!"); } The constructor property is key to mimicking a classic object-oriented system
    2010-07-11 09:09
This blog is frozen. No new comments or edits allowed.