當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
JS replace 回调
生活随笔
收集整理的這篇文章主要介紹了
JS replace 回调
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
JS中 字符串的replace函數 可以接受回調函數
例如? 一般用法: var a = '1,2,3,4,5'; var b = a.replace('2,3','*'); console.log(b); ? 輸出:'1,*,4,5'
回調函數的用法: var a = '1,2,3,4,5'; var b = a.replace(?'2,3'?,function(match){ return '*'; }); console.log(b); 輸出:'1,*,4,5'
例如? 一般用法: var a = '1,2,3,4,5'; var b = a.replace('2,3','*'); console.log(b); ? 輸出:'1,*,4,5'
回調函數的用法: var a = '1,2,3,4,5'; var b = a.replace(?'2,3'?,function(match){ return '*'; }); console.log(b); 輸出:'1,*,4,5'
轉載于:https://www.cnblogs.com/zyc-undefined/archive/2013/04/27/3153219.html
總結
以上是生活随笔為你收集整理的JS replace 回调的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: log4cxx编译过程–linux
- 下一篇: 漂亮的页面向导和Tab插件(Jquery