// nullish coalescing operator let substitute = 51; let val1 = null ?? 10; console.log(val1); //10 let val2 = undefined ?? substitute; console.log(val2); //51 let val3 = 5 ?? 8; console.log(val3); //5 let original = null; let test = undefined; let val4 = original ?? test ?? substitute console.log(val4); //51
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter