const defaultExample = (a, b) => { if (b === undefined) { b = 5 } return a + b } // Instead const defaultExample2 = (a, b = 5) => a + b console.log(defaultExample(2, 4)) console.log(defaultExample2(3))
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