看板
[ Ajax ]
討論串[問題] 如何對 String 實施繼承?
共 2 篇文章
首頁
上一頁
1
下一頁
尾頁
內容預覽:
嘗試這樣做,讓NewType與String相容:. <html>. <body>. <script>. function NewType(str) {. this._str = str;. this.toString = function() {. return this.valueOf();. }
(還有576個字)
內容預覽:
之前我寫過一組處理字串的函式. 是利用 String.prototype 新增新的介面. 但是後來覺得老是破壞別人的物件模型不太好. 想利用繼承手法來新增一個子類別. 試著用. NewType.prototype = new String;. 但是其行為並不正確. 請問是否 String 就只能用a
(還有168個字)
首頁
上一頁
1
下一頁
尾頁