# 双指针

# 反转字符串

# 回文字符串

# 正则表达式子

# 判断是否是电话号码

function isPhone(phone) {
    // ^x表示以x开头,$表示结尾,[xyz]表示xyz中的任意一个,{n}表示重复n次
    const phoneReg = /^1[35789]\d{9}$/;
    return phoneReg.test(phone);
}

# 验证是否是邮箱

function isEmail(email) {
  const emailReg = //;
  return emailReg.test(email);
}

# 验证是否是身份证

function isEmail(email) {
  const emailReg = //;
  return emailReg.test(email);
}

# 解析 URL

# 解析 URL Params 为对象

  • 获取 url 中的参数:
    • 指定参数名称,返回该参数的值 或者 空字符串
    • 不指定参数名称,返回全部的参数对象 或者 {}
    • 如果存在多个同名参数,则返回数组
    • decodeURIComponent 对中文解码

# 查找字符串中出现最多的字符和个数

# 模板引擎实现

实现效果:

let template = "我是{{name}},年龄{{age}},性别{{sex}}";
let data = {
    name: "姓名",
    age: 18,
};
render(template, data); // 我是姓名,年龄18,性别undefined