/////////////////day 3
object literal {}
object();
function(); – anonymous function
var Car = function() {
this.engine = {
shift : function(){
console.log(“shifting”);
}
}
this.steering = {
goLeft : function (){
console.log(“going left”);
},
goRight : function (){
console.log(“going right”);
}
}
}
var toyota = new Car();
toyota.steering.goLeft():
toyota.engine.shift();
///////////////////////day 4
function window (){//outermost object
this.document = new docobject();
}
function docobject(){
this.forms = new formcollection();
}
function formcollection(){
this.form1 = new formobject();
this.form2 = new formobject();
}
function formobject(){
this.elements = new elementcollection();
//console.log(“input”);
}
function elementcollection(){
this.input1 = new input();
}
function input(){
this.innerhtml = “default inner html”;
this.click = function(){
//document.onclick = inner.html;
console.log(“click”);
}
}
//
var w = new window();
w.document.forms[“form1”].elements[“input1”].click();
w.document.forms[“form1”].elements[“input1”].innerhtml = “Hi”;
console.log(w.document.forms[“form1”].elements[“input1”].innerhtml);
-you have to know how to abstract
-walk thru the code
-spelling / spaces
Leave a comment