객체 배열의 속성에 액세스하려면 다음 코드를 실행할 수 있습니다.
예시
<html> <head> <title>User-defined objects</title> <script> function book(title, author){ this.title = title; this.author = author; } </script> </head> <body> <script> var myBook = new book("PHP", "Amit"); book.prototype.price = null; myBook.price = 250; document.write("Book title is : " + myBook.title + "<br>"); document.write("Book author is : " + myBook.author + "<br>"); document.write("Book price is : " + myBook.price + "<br>"); </script> </body> </html>
출력
Book title is : PHP Book author is : Amit Book price is : 250