ecma6学习知识点(三)字符串模板及字符串新增

1.用表示字符穿模板 例如 : let name = ”yangr“ let word = `woshi ${name}`; console.log(word); //将会输出 woshi yangr 2.字符串模板可以随意换行,可以用于动态添加元素不用长的拼接字符串了。
3. includes() 方法
let aaa = “apple sdfdsfdsf”;
aaa.includes(“apple”); 返回false 或 true;
indexOf返回的是位置。
4. let str = “https://mp.csdn.net/mdeditor?not_checkout=1#”;
str.startsWith(“https”);
str.endsWith(".png");以什么结尾。
5.repeat 重复数据
let str = “牧马人 牧马人”;
console.log(str.repeat(1000)) //输出1000次
6.填充字符串
let str = “a”;
str.padStart(4,“xxx”); //4填充完的字符串的长度 结果为 xxxa
str.padEnd(4,“xxx”) // 结果为axxx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值