SOURCE

const str = 'hello world!'

// 之一:字符串的slice方法,可以截取一个字符串,返回一个新的字符串
// str.slice(start, end)
// const newStr = str.slice(0, 1)
// console.log(newStr)

// 之二:字符串的substr方法 备注:ECMAscript 没有对该方法进行标准化,因此反对使用它
// str.substr(start, count)
// console.log(str.substr(0, 3))

// 之三:字符串的substring方法 
// str.substring(from, to) 包括开始不包括结束
// console.log(str.substring(0, 1))


// 补充:字符串的charAt方法  返回字符串指定索引处的子字符串
// console.log( str.charAt(1) )

// 补充:字符串的includes方法  
// 查找字符串中是否有指定的子字符串
console.log(str.includes('h'))


console 命令行工具 X clear

                    
>
console