console.log(text.startsWith('1'))
console.log(text.endsWith('a'))
console.log(text.includes('a'))//判断是否包含‘a’'x'.repeat(3)//xxx
let text=`
<div>
</div>`.trim()//trim去掉<div>前面的空白
let text='aaa2';
let aaa=`aaaa,${text}`//aaaa,aaa2
let price=10
let conut=5
let text='aaa2';
let aaa=`aaaa,${text}$${price*conut}`//计算
function pass(str,...num){
return str[1]+num[1]
}
let count=10
let price=20
let text=pass`count is${count}and price is${price}`
console.log(text)//截取字符串进行函数处理and price is20
类:
es6标准
classPersonClass {
constructor (name) {
this.name = name
}
sayName () {
console.log(this.name)
}
}
let person = new PersonClass('Nick')
person.sayName()//Nick