एक ऑब्जेक्ट के रूप में JavaScript फ़ंक्शन का उपयोग करने के लिए, आप निम्न कोड को चलाने का प्रयास कर सकते हैं -
उदाहरण
<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("Amit", "Python");
document.write("Book title is : " + myBook.title + "<br>");
document.write("Book author is : " + myBook.author + "<br>");
</script>
</body>
</html>