September 25, 2012
Should I place a semicolon at the end of my jQuery statement?
Question by Marilou
Possible Duplicate:
Do you recommend using semicolons after every statement in JavaScript?
I have the code like this:
$("#delete_" + row)
.attr('data-href', '/Admin/' + tab + 's/Delete' + params)
.attr('title', 'Delete ' + id);
It’s typical of the code I have everywhere in my application. What I notice is that it seems to work with or without a semicolon at the end. Is there any advantage for formatting or any other reason that I should put a semicolon at the end?
Answer by Explosion Pills
Always put the semicolon. Not only is it more cross-browser compatible, it’s easier to minify (removing newlines is part of that).
Answer by Starx
Semicolons, although not required in JavaScript, denote end of statement. So its a good habit of ending a statement with semicolon at the end. Other point, Explosion Pills has already mentioned.