Function (STR, type) {switch (type) {case 1: return str.replace(/\s+/g, “”); case 2: return str.replace(/(^\s*)|(\s*$)/g, “”); case 3: return str.replace(/(^\s*)/g, “”); case 4: return str.replace(/(\s*$)/g, “”); default: return str; }} Case conversion: changeCase: function (str, type) { function ToggleCase(str) { var itemText = “” str.split(“”).forEach( function (item) { if (/^([a-z]+)/.test(item)) { itemText += item.toUpperCase(); } else if (/^([A-Z]+)/.test(item)) { itemText += item.toLowerCase(); } else { itemText += item; }}); return itemText; } switch (type) { case 1: return str.replace(/\b\w+\b/g, function (word) { return word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase(); }); case 2: return str.replace(/\b\w+\b/g, function (word) { return word.substring(0, 1).toLowerCase() + word.substring(1).toUpperCase(); }); case 3: return ToggleCase(str); case 4: return str.toUpperCase(); case 5: return str.toLowerCase(); default: return str; RepeatStr: function (STR, count) {var text = ”; for (var i = 0; i < count; i++) { text += str; } return text; } replaceAll: function (str, AFindText, ARepText) { raRegExp = new RegExp(AFindText, “g”); return str.replace(raRegExp, ARepText); CheckType: function (STR, type) {switch (type) {case ’email’: return /^[\w-]+(.[\w-]+)@[\w-]+(.[\w-]+)+$/.test(str); case ‘phone’: return /^1[3|4|5|7|8][0-9]{9}$/.test(str); Case ‘tel: return / ^ (0 \ d {2, 3} – \ d {7, 8}) (\ d {1, 4})? $/.test(str); case ‘number’: return /^[0-9]$/.test(str); case ‘english’: return /^[a-zA-Z]+$/.test(str); case ‘text’: return /^\w+$/.test(str); case ‘chinese’: return /^[\u4E00-\u9FA5]+$/.test(str); case ‘lower’: return /^[a-z]+$/.test(str); case ‘upper’: return /^[A-Z]+$/.test(str); default: return true; Function (STR) {var nowLv = 0; if (str.length < 6) { return nowLv } if (/[0-9]/.test(str)) { nowLv++ } if (/[a-z]/.test(str)) { nowLv++ } if (/[A-Z]/.test(str)) { nowLv++ } if (/[.|-|_]/.test(str)) { nowLv++ } return nowLv; Function (count) {return math.random ().toString(count).substring(2); } Find the string: countStr: Function (STR, strSplit) {return str.split(strSplit).length-1} // Filter string (HTML tags, expressions, special characters) // String, replace content (special-special characters, HTML-HTML tags, Emjoy-Emjoy expressions, Word-lowercase letters, Word-uppercase letters, number-number, Chinese-Chinese), // If multiple characters need to be filtered, the type argument uses, split, as follows // Filter string HTML tags, uppercase letters, Chinese characters, special characters, all replaced with, but special characters ‘%’, ‘? //var STR =’asd 654A sasdasdASDQWEXZC6d5#%^^&^%^&$\”‘#@! ()/() ‘” : “{}?

Ah really big pig bike these lessons ‘; // ecDo.filterStr(str,’html,WORD,chinese,special’,’‘, ‘%? ‘) //result: “ASD 654asasdasd**6d5#%^^ &^ & ^ %$” ‘# @! (a)/ – ())

var typeArr = type.split(‘,’), _str = str; for (var i = 0, len = typeArr.length; i < len; Whether i++) {/ / filter special symbol if (typeArr [I] = = = ‘special’) {var pattern, regText = ‘$() [] {}? | ^ * +. / “‘ + ‘. If (SPSTR) {var _spstr = spstr.split(“”), _regText = “[^ 0-9a-za-z \s”; for (var j = 0, len1 = _spstr.length; j < len1; j++) { if (regText.indexOf(_spstr[j]) === -1) { _regText += _spstr[j]; } else { _regText += ‘\’ + _spstr[j]; } } _regText += ‘]’ pattern = new RegExp(_regText, ‘g’); } else { pattern = new RegExp(“[^0-9A-Za-z\s]”, ‘g’) } }

var _restr = restr || ”; switch (typeArr[i]) { case ‘special’: _str = _str.replace(pattern, _restr); break; case ‘html’: _str = _str.replace(/</? [^>]*>/g, _restr); break; case ’emjoy’: _str = _str.replace(/[^\u4e00-\u9fa5|\u0000-\u00ff|\u3002|\uFF1F|\uFF01|\uff0c|\u3001|\uff1b|\uff1a|\u3008-\u300f|\u2018|\u2019 |\u201c|\u201d|\uff08|\uff09|\u2014|\u2026|\u2013|\uff0e]/g, _restr); break; case ‘word’: _str = _str.replace(/[a-z]/g, _restr); break; case ‘WORD’: _str = _str.replace(/[A-Z]/g, _restr); break; case ‘number’: _str = _str.replace(/[0-9]/g, _restr); break; case ‘chinese’: _str = _str.replace(/[\u4E00-\u9FA5]/g, _restr); break; } } return _str; } string: // ecdo. formatText(‘ 1234ASDA567ASD890 ‘) //result: FormatText (‘ 1234ASda567ASd890 ‘,4, “) //result: “1 234a sda5-67as d890” // ecdo. formatText(‘ 1234ASda567ASd890 ‘,4,’-‘) //result: “1-234a sda5-67as d890” formatText: function (str, size, delimiter) { var _size = size || 3, _delimiter = delimiter || ‘,’; var regText = ‘\B(? =(\w{‘ + _size + ‘})+(? ! \w))’; var reg = new RegExp(regText, ‘g’); return str.replace(reg, _delimiter); }

// ecdo. longestWord(‘Find the Longest word in a String’) //result: 7 / / ecDo. LongestWord (‘ Find | the | Longest | word | | in the | a String ‘, ‘|’) / / result: 7 longestWord: function (str, splitType) { var _splitType = splitType || /\s+/g, _max = 0,_item=”; var strArr = str.split(_splitType); strArr.forEach(function (item) { if (_max < item.length) { _max = item.length _item=item; } }) return {el:_item,max:_max}; }

Capitalize the first letter of a word in a sentence: // I have been struggling with this. Even if the title is capitalized, not every word is capitalized, but I don’t know which one should be capitalized. // ecdo.titlecaseup (‘this is a title’) //” this is a title “titleCaseUp: function (str, splitType) { var _splitType = splitType || /\s+/g; var strArr = str.split(_splitType), result = “”, _this = this strArr.forEach(function (item) { result += _this.changeCase(item, 1) + ‘ ‘; }) return this.trim(result, 4) }

RemoveRepeatArray: function (arr) { return arr.filter(function (item, index, self) { return self.indexOf(item) === index; }); }

UpsetArr: function (arr) {return arr.sort(function () {return math.random () -0.5}); // maxArr: function (arr) {return math.max. apply(null, arr); }, // array minArr: function (arr) {return math.min. apply(null, arr); }

// Summation sumArr: Function (arr) {return arr. Reduce (function (pre, cur) {return pre + cur})} covArr: function (arr) { return this.sumArr(arr) / arr.length; } function (arr) {return arr[math.floor (math.random () * arr.length)]; } return string (array) the number of occurrences of an element: // ecdo. getEleCount(‘asd56+ asdasdwQE ‘,’a’) GetEleCount ([1,2,3,4,5,66,77,22,55,22],22) //result: 2 getEleCount: function (obj, ele) {var num = 0; for (var i = 0, len = obj.length; i < len; i++) { if (ele === obj[i]) { num++; } } return num; ### //arr, rank-> length, default array length, ranktype, default descending order // El – > element, the count number – > / / ecDo getCount (,2,3,1,2,5,2,4,1,2,6,2,1,3,2 [1]) / / by default, returns the number of occurrences of all elements / / result: [{“el”:”2″,”count”:6},{“el”:”1″,”count”:4},{“el”:”3″,”count”:2},{“el”:”4″,”count”:1},{“el”:”5″,”count”:1},{“el”:”6″,”cou Nt “: 1}] / / ecDo. GetCount (,2,3,1,2,5,2,4,1,2,6,2,1,3,2] [1, 3) / / transfer (rank = 3), only to return to the occurrences before ordering three / / result: [{” el “, “2”, “count” : 6}, {” el “:” 1 “, “count” : 4}, {” el “:” 3 “, “count” : 2}] / / ecDo getCount (,2,3,1,2,5,2,4,1,2,6,2,1,3,2 [1], null, 1) // return the number of occurrences of all elements in ascending order. //result: [{“el”:”6″,”count”:1},{“el”:”5″,”count”:1},{“el”:”4″,”count”:1},{“el”:”3″,”count”:2},{“el”:”1″,”count”:4},{“el”:”2″,”cou Nt: 6} “] / / ecDo getCount (,2,3,1,2,5,2,4,1,2,6,2,1,3,2] [1, 3, 1) / / mass participation (rank = 3, ranktype = 1), only to return to the occurrences sort (ascending) / / result in the first three: [{“el”:”6″,”count”:1},{“el”:”5″,”count”:1},{“el”:”4″,”count”:1}] getCount: Function (arr, rank, rankType) {var obj = {}, k, arr1 = [

for (var i = 0, len = arr.length; i < len; i++) { k = arr[i]; if (obj[k]) { obj[k]++; } else { obj[k] = 1; For (var o in obj) {arr1.push({el: o, count: obj[o]}); } // sort(function (n1, n2) {return n2.count – n1.count}); // Reverse the array if (rankType === 1) {arr1 = arr1.reverse(); } var rank1 = rank || arr1.length; return arr1.slice(0, rank1); }

Get n1, n2 subscript arrays: / / ecDo getArrayNum (,1,2,3,4,5,6,7,8,9 0 and 3, 5, 9) / / result: [5, 6, 7, 8, 9] / / getArrayNum (,1,2,3,4,5,6,7,8,9] [0, 2) / / don’t pass the second parameter, the default return from n1 to the end of the array elements / / the result: [2, 3, 4, 5, 6, 7, 8, 9] getArrayNum: function (arr, n1, n2) { return arr.slice(n1, n2); } filter array: / / delete a value of ‘val array elements / / ecDo removeArrayForValue ([‘ test’, ‘test1’, ‘test2’, ‘test’, ‘aaa’], ‘test’, ‘) / / result: (” aaa “) with a ‘test’ delete all / / ecDo removeArrayForValue ([‘ test ‘, ‘test1’, ‘test2’, ‘test’, ‘aaa’], ‘test’) / / result: [“test1”, “test2”, “aaa”] removeArrayForValue: function (arr, val, type) { return arr.filter(function (item) { return type ? item.indexOf(val) === -1 : item ! == val})} get some items of the object array: //var arr=[{a:1,b:2,c:9},{a:2,b:3,c:5},{a:5,b:9},{a:4,b:2,c:5},{a:4,b:5,c:7}] //ecDo.getOptionArray(arr,’a,c’) / / result: [{a: 1, c: 9}, {2, a: c: 5}, {5, a: c: underfind}, {a: 4, c: 5}, {a: 4, c: 7}] / / ecDo getOptionArray (arr, ‘b’) / / result: [2, 3, 9, 2, 5] getOptionArray: function (arr, keys) { var newArr = [] if (! keys) { return arr } var _keys = keys.split(‘,’), newArrOne = {}; If (_keys.length === 1) {for (var I = 0, len = arr.length; i < len; i++) { newArr.push(arr[i][keys]) } return newArr; }

for (var i = 0, len = arr.length; i < len; i++) { newArrOne = {}; for (var j = 0, len1 = _keys.length; j < len1; j++) { newArrOne[_keys[j]] = arr[i][_keys[j]] } newArr.push(newArrOne); } return newArr }

Rule out an array of objects of certain items / / var arr = [{2, a: 1, b: c: 9}, {3, 2, a: b: c: 5}, {5, a: b: 9}, {2, a: 4, b: c: 5}, {5, a: 4, b: c: 7}] / / ecDo. FilterOptionArray (arr, ‘a’) / / result: : [{b, c: 9}, {3, b: c: 5}, {b: 9}, {2, b: c: 5}, {5, b: c: 7}] / / ecDo filterOptionArray (arr, ‘a, c’) / / result: [{b:2},{b:3},{b:9},{b:2},{b:5}] filterOptionArray: function (arr, keys) { var newArr = [] var _keys = keys.split(‘,’), newArrOne = {}; for (var i = 0, len = arr.length; i < len; i++) { newArrOne = {}; If (_keys.indexof (key) === -1) {newArrOne[key] = arr[I][key]; if (_keys.indexof (key) === -1) {newArrOne[key] = arr[key]; } } newArr.push(newArrOne); } return newArr }

Object array sort: / / var arr = [{2, a: 1, b: c: 9}, {3, 2, a: b: c: 5}, {5, a: b: 9}, {2, a: 4, b: c: 5}, {5, a: 4, b: c: 7}] / / ecDo arraySort (arr, ‘a, b) a is the first order conditions, //result: [{“a”:1,”b”:2,”c”:9},{“a”:2,”b”:3,”c”:5},{“a”:4,”b”:2,”c”:5},{“a”:4,”b”:5,”c”:7},{“a”:5,”b”:9}] arraySort: function (arr, sortText) { if (! sortText) { return arr } var _sortText = sortText.split(‘,’).reverse(), _arr = arr.slice(0); for (var i = 0, len = _sortText.length; i < len; i++) { _arr.sort(function (n1, n2) { return n1[_sortText[i]] – n2[_sortText[i]] }) } return _arr; }

Array flattening: / / ecDo. Steamroller ([1, 2, [4, 5, [1, 10]]]) / / [1, 2, 4, 5, 1, 23] steamroller: function (arr) { var newArr = [],_this=this; for (var i = 0; i < arr.length; I ++) {if (array.isarray (arr[I])) { Apply (newArr, _this.steamroller(arr[I])); } else {// Not array push directly into newArr newarr.push (arr[I]); } } return newArr; }

Basic DOM manipulation: this part of the code actually refers to some functions written in jquery, the only difference is that the call is not used, the parameters are the same. $(‘# XXX ‘).html(‘hello world’); $(‘# XXX ‘).html(); $(‘# XXX ‘).html(); Now: ecDo. HTML (document. GetElementById (‘ XXX ‘))

HasClass: function (obj, classStr) {if (obj. ClassName && this. Trim (obj. ClassName, 1)! == “”) { var arr = obj.className.split(/\s+/); Return (arr.indexof (classStr) == -1); false : true; } else { return false; }}

AddClass name: addClass: function (obj, classStr) { if ((this.istype(obj, ‘array’) || this.istype(obj, ‘elements’)) && obj.length >= 1) { for (var i = 0, len = obj.length; i < len; i++) { if (! this.hasClass(obj[i], classStr)) { obj[i].className += ” ” + classStr; } } } else { if (! this.hasClass(obj, classStr)) { obj.className += ” ” + classStr; }}}

Delete class name: removeClass function (obj, classStr) { if ((this.istype(obj, ‘array’) || this.istype(obj, ‘elements’)) && obj.length > 1) { for (var i = 0, len = obj.length; i < len; i++) { if (this.hasClass(obj[i], classStr)) { var reg = new RegExp(‘(\s|^)’ + classStr + ‘(\s|$)’); obj[i].className = obj[i].className.replace(reg, ”); } } } else { if (this.hasClass(obj, classStr)) { var reg = new RegExp(‘(\s|^)’ + classStr + ‘(\s|$)’); obj.className = obj.className.replace(reg, ”); }}}

ReplaceClass: function (obj, newName, oldName) {this.removeclass (obj, oldName); this.addClass(obj, newName); // ecdo.getendTime (‘2017/7/22 16:0:0’) //result: “remaining time 6 days 2 hours 28 minutes 20 seconds” getEndTime: function (endTime) { var startDate = new Date(); Var endDate = new Date(endTime); Var t = enddate.getTime () -startDate.getTime (); Var d = 0, h = 0, m = 0, s = 0; if (t >= 0) { d = Math.floor(t / 1000 / 3600 / 24); h = Math.floor(t / 1000 / 60 / 60 % 24); m = Math.floor(t / 1000 / 60 % 60); s = Math.floor(t / 1000 % 60); } return “rest” + d + + h + “hour” + “day” m + “minutes” + s + “seconds”; } rem getFontSize: function (_client) {var doc = document, win = window; var docEl = doc.documentElement, resizeEvt = ‘orientationchange’ in window ? ‘orientationchange’ : ‘resize’, recalc = function () { var clientWidth = docEl.clientWidth; if (! clientWidth) return; // If the screen is larger than 750 (750 is set according to my renderer), set clientWidth=750, If (clientWidth > _client) {clientWidth = _client} // Set the root element size docel.style. fontSize = 100 * (clientWidth / _client) + ‘px’; }; Win.addeventlistener (resizeEvt, recalc, false); When the document is loaded, the function doc.addEventListener(‘DOMContentLoaded’, recalc, false) is triggered; } // ecdo.getfontSize (750) // The width and height are 100px; Img {width:1rem; height:1rem; } // For example, on devices with a screen width of 750px or more, 1rem=100px; For example, on iphone6(screen width: 375), 375/750100=50px; Rem is 1 = 50 px; The image shows 50px width and height; Encapsulating Ajax functions: / Encapsulating Ajax functions

  • @param {string}obj.type HTTP connection mode, including POST and GET
  • @param {string}obj.url Specifies the URL to send the request
  • @param {Boolean}obj. Async Specifies whether the request is asynchronous. The value can be true or false
  • @param {object}obj.data Specifies the parameters to be sent. The format is object type
  • @param {function}obj.success Ajax sends and receives successfully called callback functions
  • @param {function}obj.error Ecdo. ajax({// type:’get’, // url:’ XXX ‘, // data:{ // id:’111’ // }, // success:function(res){ // console.log(res) // } // })

ajax: function (obj) { obj = obj || {}; obj.type = obj.type.toUpperCase() || ‘POST’; obj.url = obj.url || ”; obj.async = obj.async || true; obj.data = obj.data || null; obj.success = obj.success || function () { }; obj.error = obj.error || function () { }; var xmlHttp = null; if (XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } else { xmlHttp = new ActiveXObject(‘Microsoft.XMLHTTP’); } var params = []; for (var key in obj.data) { params.push(key + ‘=’ + obj.data[key]); }

var postData = params.join(‘&’); if (obj.type.toUpperCase() === ‘POST’) { xmlHttp.open(obj.type, obj.url, obj.async); xmlHttp.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded; charset=utf-8’); xmlHttp.send(postData); } else if (obj.type.toUpperCase() === ‘GET’) { xmlHttp.open(obj.type, obj.url + ‘? ‘ + postData, obj.async); xmlHttp.send(null); } xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { obj.success(xmlHttp.responseText); } else { obj.error(xmlHttp.responseText); }}; }

Function (obj, url, errorUrl,cb) {var oImg = new Image(), _this = this; oImg.src = url; oImg.onload = function () { obj.src = oImg.src; if (cb && _this.istype(cb, ‘function’)) { cb(obj); } } oImg.onerror=function () { obj.src=errorUrl; if (cb && _this.istype(cb, ‘function’)) { cb(obj); // @classname {string} //@num {number} // @classname {string} //@num {number} // So when the page scrolls to 2800, the image loads. // HTML code // is loaded when the page reaches 3000

loadImg: function (className, num, errorUrl) { var _className = className || ‘ec-load-img’, _num = num || 0, _this = this,_errorUrl=errorUrl||null; var oImgLoad = document.getElementsByClassName(_className); for (var i = 0, len = oImgLoad.length; i < len; I++) {/ / if the image has scroll to specify the height of the if (document. DocumentElement. ClientHeight + document. DocumentElement. ScrollTop > oImgLoad[i].offsetTop – _num && ! OImgLoad [I]. IsLoad = true; OImgLoad [I].style.csSText = “transition: “; opacity: 0;” If (oImgLoad[I].dataset) {this.aftLoadimg (oImgLoad[I], oImgLoad[I].dataset. SRC, _errorUrl, function (o) {// Add timer, SetTimeout (function () {if (o.isload) {_this.removeclass (o, _className); o.style.cssText = “”; }}, 1000)}); } else {

This.aftloadimg (oImgLoad[I], oImgLoad[I].getAttribute(“data-src”), _errorUrl, function (o) {// Add timer to make sure that the image has been loaded, SetTimeout (function () {if (o.isload) {_this.removeclass (o, _className); o.style.cssText = “”; }}, 1000)}); } (function (i) { setTimeout(function () { oImgLoad[i].style.cssText = “transition:all 1s; opacity: 1;” ; }, 16) })(i); }}}

Keywords tag / / these two functions is used to search the key words highlighted / / create a regular characters / / ecDo createKeyExp ([front end, over]) / / result: (front end |)/g createKeyExp: function (strArr) { var str = “”; for (var i = 0; i < strArr.length; i++) { if (i ! = strArr.length – 1) { str = str + strArr[i] + “|”; } else { str = str + strArr[i]; } } return “(” + str + “)”; }, // keyword tag (multiple keywords with space) // ecdo.findKey (‘ shouhou I oaks received from the next time you leave happy jiji stay in Kaesong ‘,’ Shouhou kai ‘,’ I ‘) //” Shouhou I oaks received from the next time you leave happy jiji stay in Kaesong “findKey: function (str, key, el) { var arr = null, regStr = null, content = null, Reg = null, _el = el || ‘span’; arr = key.split(/\s+/); //alert(regStr); / / such as: (front end |) regStr = this. CreateKeyExp (arr); content = str; //alert(Reg); / / / such as: (front end |)/g Reg = new RegExp (regStr, “g”); // Filter HTML tags replace tags by adding tags before and after keywords content = content.replace(/
]*>/g, ”) return content.replace(Reg, “<” + _el + “>$1
“); } data types: / / ecDo istype ([], ‘array’) / / true / / ecDo istype ([]) / / ‘[object array]’ istype: function (o, type) { if (type) { var _type = type.toLowerCase(); } switch (_type) { case ‘string’: return Object.prototype.toString.call(o) === ‘[object String]’; case ‘number’: return Object.prototype.toString.call(o) === ‘[object Number]’; case ‘boolean’: return Object.prototype.toString.call(o) === ‘[object Boolean]’; case ‘undefined’: return Object.prototype.toString.call(o) === ‘[object Undefined]’; case ‘null’: return Object.prototype.toString.call(o) === ‘[object Null]’; case ‘function’: return Object.prototype.toString.call(o) === ‘[object Function]’; case ‘array’: return Object.prototype.toString.call(o) === ‘[object Array]’; case ‘object’: return Object.prototype.toString.call(o) === ‘[object Object]’; case ‘nan’: return isNaN(o); case ‘elements’: return Object.prototype.toString.call(o).indexOf(‘HTML’) ! = = 1 default: return Object. The prototype. ToString. Phone call (o)}} type judgment: browserInfo: function (type) { switch (type) { case ‘android’: return navigator.userAgent.toLowerCase().indexOf(‘android’) ! == -1 case ‘iphone’: return navigator.userAgent.toLowerCase().indexOf(‘iphone’) ! == -1 case ‘ipad’: return navigator.userAgent.toLowerCase().indexOf(‘ipad’) ! == -1 case ‘weixin’: return navigator.userAgent.toLowerCase().indexOf(‘micromessenger’) ! == -1 default: return navigator.userAgent.toLowerCase() } }

Var count=0; var count=0; // function fn1(){ // count++; // console.log(count) //} // // the number of consecutive calls triggered within 100ms, the last call will process the wait of the previous call, // document.onmousemove= ecdo.delayfn (fn1,100,200) delayFn: function (fn, delay, mustDelay) { var timer = null; var t_start; return function () { var context = this, args = arguments, t_cur = +new Date(); // Clear the last call trigger (the last call trigger event is not executed) clearTimeout(timer); // If there is no trigger time, the current time is trigger time if (! t_start) { t_start = t_cur; }

If (t_cur-t_start >= mustDelay) {fn.apply(context, args); // If (t_cur-t_start >= mustDelay); t_start = t_cur; Else {timer = setTimeout(function () {fn.apply(context, args); }, delay); }}; Trim =function(type){case 1:return this.replace(/\s+/g,””); case 2:return this.replace(/(^\s*)|(\s*$)/g, “”); case 3:return this.replace(/(^\s*)/g, “”); case 4:return this.replace(/(\s*$)/g, “”); default:return this; }}

//’ 123456896 ‘. Trim (1) //”123456896″ // easier than trim(‘ 123456896 ‘,1). // However, this is not recommended. It pollutes the native String, and other strings created by others will also be contaminated, causing unnecessary overhead. // To make matters worse, if you name your method the same as the original method, Is cover the original method / / String prototype. The substr = function () {the console. The log (‘ asdasd)} / / ‘asdasdwe46546 substr () / / asdasd // What does substr do? If not, go to w3c

Var ecDo={trim:function(){.. }, changeCase:function(){.. }… }