kalpana jaiswal

kalpana jaiswal

  • NA
  • 45
  • 9.8k

Objects In Javascript.

Dec 3 2017 11:02 AM
<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)