Example 8.6
You drove a distance of 275 miles.
Example 8.7
The soldier's name is Tina Savage.
Tina Savage's rank is captain
Example 8.8
Make: Honda Civic
Year: 2009
Price: 30000
Owner: Henry Lee
Example 8.9
The title is A Child's Garden of Verses
The author is Robert Lewis Stevenson
The publisher is Little Brown
Example 8.10
myBook.title2 = JavaScript by Example
myBook.author2 = Ellis
myBook.publisher2 = Prentice Hall
myBook.show = function show() {
with(this) {
var info = "The title is " + title2;
info += "
The author is " + author2;
info += "
The publisher is " + publisher2 + "
";
document.write(info);
}
}
myBook.show2 = function show2(obj, name) {
var result = "";
for (var prop in obj) {
result += name + "." + prop + " = " + obj[prop] + "
";
}
return result;
}
Example 8.11
Kidnapped is published by Penguin Books
Tale of Two Cities is published by undefined
Example 8.12
Kidnapped is published by Penguin Books
Tale of Two Cities is published by Penguin Books
Example 8.13
Kidnapped is published by Penguin Books and is in the Fiction category
Tale of Two Cities is published by Penguin Books and is in the Fiction category
Example 8.14
title4 = War and Peace
author4 = Leo Tolstoy
price4 = 30
show3 = function showProps() {
var result = "";
for (var i in this) {
result += i + " = " + this[i] + "
";
}
return result;
}
addTax = function addTax() {
this.price4 *= 1.18;
return (this.price4.toFixed(2));
}
category = Fiction
title4 = JavaScript by Example
author4 = Ellie Quigley
price4 = 25
show3 = function showProps() {
var result = "";
for (var i in this) {
result += i + " = " + this[i] + "
";
}
return result;
}
addTax = function addTax() {
this.price4 *= 1.18;
return (this.price4.toFixed(2));
}
category = Fiction
With tax "War and Peace" costs $35.40.
With tax "JavaScript by Example" costs $29.50.
Example 8.15
The value of Object's category property is Fiction
tale is a Book object
The Book's constructor is defined as: function Book3(title3, author3) {
this.title3 = title3;
this.author3 = author3;
}
The object has an author property.
Book is a prototype of object tale.
tale is an instance of Book.
tale is an instance of Object.
Example 8.16
The cat is a Female owned by John Doe and it says Meow
The dog is a Male owned by Mrs. Jones and it says Woof
Exercise #1 on Page 211
The circle's diameter is 4.
The circle's circumference is 12.56.
Exercise #2 on Page 211
That was not a valid entry. Time is up
Exercise #4 on Page 211
Joel 423-123-1234
Bobby 423-345-3456
Tracy 423-678-6789