zoukankan      html  css  js  c++  java
  • js原型

    String.prototype用于为某字符串对象新增方法,比如:
    在javascript中有一方法replace,它是用于替换某字符串中第一个匹配的字符,如果我们想为它追加一个循环匹配所有字符的方法时,可以这样子:
    String.prototype.replaceAll = function(oldStr, newStr) {
       return this.replace(new RegExp(oldStr,"gm"),newStr); 
    }
    var bodyString = $("body").html().replaceAll("surf","只是个传说");
    这样子,凡是在body中出现了"surf"类似的字符,就会被替换为"只是个传说"了。
    http://www.cnblogs.com/seasons1987/p/3205838.html
     
     
  • 相关阅读:
    pycharm路径
    git常用命令
    分页
    router
    视图集
    Leanring TypeScript 中文版
    RXJS 系列 04
    RXJS 系列 03
    RXJS 系列 02
    RXJS 系列 01
  • 原文地址:https://www.cnblogs.com/geekjsp/p/6734314.html
Copyright © 2011-2022 走看看