|||-begingit
var url = 'http://qq.com'
|||-endes6
let a = 12 let str1 = `asdf${a}` console.log(str1)
startsWith
endsWith
var url = 'http://qq.com'
console.log(url.startsWith('http'))
console.log(url.endsWith('com'))
// 都是 true加密
使用反引號,${變量}
能夠折行
let a = 12
let str1 = `asdf${a}`
console.log(str1)
let title = '標題'
let content = '內容'
let str = `<div>
<h1>${title}</h1>
<p>${content}</p>
`
console.log(str)
<div>
<h1>標題</h1>
<p>內容</p>url
let str="https://www.baidu.com" if(str.startsWith("http://")){ alert("普通網址") }else if(str.startsWith("https://")){ alert("加密網址") }else if(str.startsWith("git://")){ alert("git地址") }else{ alert("其餘") }
let str1='a' let str2="b" //數據中使用較多 let str3=`a${str2}`//ab let str4=`<div> <h1>${title}</h1> </div>`