zoukankan      html  css  js  c++  java
  • 用最简洁代码实现indexOf方法

    function fn(str, target) {
        let res = new RegExp(target, 'g').exec(str)
        return res ? res.index : -1
    }
    
    console.log('打印', fn('hello word', 'l'))
    // 打印 2
    
  • 相关阅读:
    3
    2
    1
    11
    12
    8888888888
    99999999999
    88888888888
    77777777
    10.23
  • 原文地址:https://www.cnblogs.com/liea/p/12508707.html
Copyright © 2011-2022 走看看