1 slice截取
2 filter这个es6新增的方法
<!-- 去掉字符串最后一个字符 -->
<script>
// 方法一,利用slice截取的功能
let foo = 'stylojd'
console.log(foo.slice(0, foo.length - 1))
//方法二,利用字符串转换为数组截取,通过使用filter这个es6新增的方法进行截取
let two = 'hahhal'
console.log(two.split(''))
let two1 = two.split('')
let two2 = two1.filter(function (value, i) {
return i !== two1.length - 1
})
console.log(two2.join(''))
</script>