Objects Flashcards
(3 cards)
1
Q
Can an object contain functions?
If so, what is the simple implementation of a function in an object?
A
Yes.
var myObj = { idProp: "1", nameProp: "Honda" drive: function(){ alert("Driving!"); } }
2
Q
Define an object “myObj” with two properties: “idProp” and “NameProp”. Set idProp to 1 and nameProp to “George”
A
var myObj = { idProp: 1, nameProp: "George" };
3
Q
Define an array “myArr” that holds 2 objects. First object has 2 properties: “propOne” and “propTwo” with values 7 and “Text” respectively. Second object has one property - “secObjPropOne” and its value is 54
A
var myArr = [ {propOne: 7, propTwo: "Text"}, {secObjPropOne: 54} ];