1. 可选链操作符( ?. )
const Obj = {}
var name = Obj.info?Obj.info.name:""
console.log(name)
var name = Obj.info?.name
console.log(name)
2. ~~运算符
var numStr = '123'
console.log(parseInt(numStr));
var numStr = '123'
console.log(~~numStr);
var numStr = '我不是数字123'
console.log(parseInt(numStr))
var numStr = '我不是数字123'
console.log(~~numStr)
3. 管道运算符( |> ) 这是一个实验中的功能
let url = "%21" |> decodeURI;
let url = decodeURI("%21");
const getSchool = (name) => `${name}, 就读清华大学`
const getInfo = (name) => `${name}, 我今年18岁`
const getName = (title) => title + "张三"
getSchool(getInfo(getName("我的名字叫:")))
"我的名字叫:" |> getName |> getInfo|> getSchool
参考