1 字符串比较

let msg = “hello vue”;
//最后一个是否包含 返回boolbean
console.log(msg.includes(“h”));
//第一个是否包含 返回boolbean
console.log(msg.startsWith(“h”));
//最后一个是否包含 返回boolbean
console.log(msg.endsWith(“h”));

//最后一个是否包含 返回num 0包含 -1不包含
console.log(msg.indexOf(“h”));

2 模板方法使用

//模板方法拼接
let name =“xiaojinlu”;
let url = http://localhost:8081/user/list?name=${name};
console.log(url);

//模板方法计算
let after = 3;
let befer = 5;
let count = ${after+befer};

console.log("aafter + befer = " + count );

//模板方法获取对象信息, 或者调用方法

let person = {name:“xiaojinlu”,age:30,jmup(){
return “fly”;
}}

console.log(name = ${person.name} , age = ${person.age} ,jump method ${person.jmup()} );
console.log(msg);

总结

//这个一定要使用注意注意注意 ``
这个英文模式下打出来
浅谈 es6 字符串使用

相关文章:

  • 2021-06-21
  • 2021-11-13
  • 2021-06-19
  • 2021-04-26
  • 2018-02-05
  • 2021-11-13
  • 2021-11-18
  • 2019-02-12
猜你喜欢
  • 2019-05-19
  • 2021-11-13
  • 2021-09-05
  • 2021-08-20
  • 2021-12-19
  • 2022-01-03
  • 2021-10-15
相关资源
相似解决方案