'2012/09/27'에 해당되는 글 1건

  1. 2012.09.27 javascript oop
posted by Remember Me, 2012.09.27 11:28


 function Book(title, chapter1, chapter2) {

this.title = title;

this.chapter1 = chapter1;

this.chapter2 = chapter2;

}

Book.prototype.toString = function() {

var message = "Outline : " + this.title + "\n" +

  "Chapter 1: " + book.chapter1.title + "\n" +

  "Chapter 2: " + book.chapter2.title + "\n";

return message;

}

function Chapter(title, page) {

this.title = title;

this.page = page;

}


var book = new Book("code craft", new Chapter("1","100"), new Chapter("2","200"));


alert(book.toString());




신고

티스토리 툴바