Home
Run >
<!DOCTYPE html> <HTML> <TITLE>Javascript String Constructor Example</TITLE> <HEAD> <script type="text/javascript"> //constructor example code var str = new String( "This is string" ); document.write("str.constructor is:" + str.constructor + "</br>"); //length example code var str = new String( "This is string" ); document.write("str.length is:" + str.length + "</br>"); function book(title, author) { this.title = title; this.author = author; } var myBook = new book("Javascript", "Jimi"); book.prototype.price = null; myBook.price = 100; 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> </HEAD> <BODY> </BODY> </HTML>