Just realized it exists, thanks to VSCode enforcing it...
Usage
let regex = /hot/g;
let phrase = "It's hot, outside.";
// you don't need to worry about null
let matches = phrase.match(regex)?.length;
That feature is called optional chaining . This calls the method when the receiver is neither undefined
nor null
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.