Miêu tả

Một constructor trả về một tham chiếu tới hàm string mà tạo prototype của instance.

Cú pháp

Cú pháp của nó như sau:

string.constructor

Trả về giá trị

Trả về hàm mà tạo instance của đối tượng.

Ví dụ

<html>
   <head>
      <title>JavaScript String constructor Method</title>
   </head>
   
   <body>
   
      <script type="text/javascript">
         var str = new String( "This is string" );
         document.write("str.constructor is:" + str.constructor); 
      </script>
      
   </body>
</html>

Kết quả

str.constructor is: function String() { [native code] } 

Các bài học JavaScript khác tại s2sontech:




Bình luận (0)

Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Michael Gough
Learning English Everyday