ES6个人笔记记录——字符串扩展

关于ES6的一些学习笔记

// console.log("\u0061");
console.log("\uD842\uDF02");
let s1 = "好";
console.log("好",s1.length);
let s = "𠬂";
console.log(s,s.length,s.charAt(0),s.charAt(1),s.charCodeAt(0),s.charCodeAt(1));

// codePointAt()
let s2 = "𠬂a";
console.log(s2.codePointAt(0),s2.charCodeAt(1),s2.charCodeAt(2));

// 字符串遍历器接口
let s3 = "whmjack";
let arr1 = [];
for(let sT of s3){
	arr1.push(sT);
	console.log(sT);
}
console.log(arr1);

模板字符串

模板字符串( template string )是增强版的字符串, 
用反引号( 、 )标识。 
它可以当作普通字 符串使用, 
也可以用来定义多行字符串, 
或者在字符串中嵌入变量。
let [name,age] = ["wjy",12];
console.log(`name=${name}
	age=${age}`);


// 标签模板
let [a1,b1] = [5,10];
function tag(s,v1,v2) {
	console.log(s[0]);
	console.log(s[1]);
	console.log(s[2]);
	console.log(v1);
	console.log(v2);
	console.log(Array.prototype.slice.call(arguments));
	return "OK";
}

tag`Hello ${ a1 + b1 } world ${ a1 * b1 }`
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值