Are semicolons required in JavaScript?
No, semicolons are not required in JavaScript. The language has a rule called automatic semicolon insertion, and it inserts a semicolon in the places where the program could not be understood without one. That is why two files with exactly the same meaning can look completely different on the screen, and both of them are valid.
The rule is careful and conservative. A semicolon is only inserted when the next token cannot continue the current statement. If a line ends with a value and the next line starts with a name, a square bracket, a round bracket, or a template string, the parser treats the next line as a continuation and inserts nothing.
That careful behaviour is the reason the dangerous cases are the ones where the next line begins with a character that could also start a new statement. Those characters are an opening round bracket, an opening square bracket, a plus sign, a minus sign, a slash, and a backtick. A file that leaves out semicolons has to protect those lines, usually by starting the line with a semicolon, or by arranging the code so that the confusing line never sits at the start of a line.
There is also a small family of places where a semicolon is always inserted, even when the next line looks like a continuation. The keyword return is the classic example. A line break directly after return ends the statement there, so the value on the next line is never returned. The same rule applies to throw, break, continue, and the operator that adds one to a value after it.
So the short answer for an interview is this. Semicolons are optional, the language inserts them for you in a set of well-defined situations, and the safe habit is to either always write them or to always leave them out and know the few places where the two rules meet badly.