1
Answer

Objects In Javascript.

kalpana jaiswal

kalpana jaiswal

6y
155
1
<html>
<head>
<title>User-defined objects</title>
<script type="text/javascript">
function book(title, author){
this.title = title;
this.author = author;
}
</script>
</h ead>
<body>
<script type="text/javascrAipt">
var myBook = new book("Perl", "Mohtashim");
document.write("Book title is : " + myBook.title + "<br>");
document.write("Book author is : " + myBook.author + "<br>");
</script>
</body>
</html>
 
 in above code we have not declare title and author in function then how i am able to access it without any error. bec according to oops programing concept we can use variable without its declaration....

Answers (1)