顯示廣告
隱藏 ✕
看板 Mesak
作者 mesak (Mesak)
標題 [JS] 幫你的類別增加功能
時間 2013年06月14日 Fri. PM 03:07:13


本文引用自:
http://blog.eddie.com.tw/2011/11/19/extend-functionality-for-your-class/

String.prototype.repeat = function(n) {
  return Array(n + 1).join(this);
};
String.prototype.downcase = function() {
  return this.toLowerCase();
};
String.prototype.upcase = function() {
  return this.toUpperCase();
};
String.prototype.find = function(str) {
  return this.indexOf(str);
};
String.prototype.has = function(str) {
  return (this.indexOf(str)) >= 0;
};



--
Mesak Blog
http://mesak.oow.me
--
※ 作者: mesak 時間: 2013-06-14 15:07:13
※ 編輯: mesak 時間: 2013-06-14 16:48:05
※ 看板: Mesak 文章推薦值: 0 目前人氣: 0 累積人氣: 124 
r)回覆 e)編輯 d)刪除 M)收藏 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇