JavaScript JavaScript and the DOM Making Changes to the DOM Getting and Setting Text with textContent and innerHTML

Murilo de Melo
Murilo de Melo
13,942 Points

Why sometimes does such block of code have semicolon at the end and sometimes not?

Minute 04:23 button.addEventListener('click', () => {}) was executed without semicolon at end. I see at some other sources as well. It's sometimes confusing for me to know whether in terms of syntax it doesn't need it or whether it does but porgram runs anyway.

Tnx

2 Answers

It's developer personal choice. To end the event listener with a semicolon or not but most of them use semicolon. When there will be thousands of lines of code, this comes handy.

Murilo de Melo
Murilo de Melo
13,942 Points

Great. Thank you beverlygrant