question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"use strict" without a semicolon

See original GitHub issue

Is it ok to use "use strict" without a semicolon at the end?
I’ve looked around the web, and everywhere there is an example with "use strict";

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Reactions:3
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
fatcommented, Feb 13, 2012

I’m sorry you think bootstrap’s javascript promotes poor coding practices. That’s definitely not my intention.

I don’t think i’ve said “because i said so” - or at least i hope i haven’t.

And as always, i’m definitely up for discussion around every part of this project, which is why it’s open source to begin with.

My current rationale is that the bootstrap plugins are simple enough, that * unnecessary* semicolons are unwarranted. I have a pretty good understanding of ASI (according to some test @sayrer tried to troll me with a long while back) and I prefer the ascetic of the code this way. The only problems I’ve heard people bring up from the lack of semicolons are:

  • it doesn’t pass jslint
  • it doesn’t match the spec
  • it doesn’t work with my minifier

I’m sympathetic to the latter - which is why we used to have a semicolon at the end of all the files (incase the minifer you were using was truly awful).

However i was under the impression that people didn’t care anymore after we added the custom downloader which offers the minified concatenated version. If this isn’t the case - i’m happy to add the semicolons back to the end of the file.

I’m less concerned with the spec - where because a semicolon is automatically inserted after the line, I believe it is still being satisfied (clearly this is the case as warnings are correctly thrown in chrome). Also, remember, this is only present as something to help us as developers… if it works in chrome and firefox, which is presumably where we are developing, so it works 😃

That all said, I don’t hate semicolons. In fact i use them in several of my other projects (hogan.js for example). It just doesn’t make sense for me here. If you disagree - let me know why? thanks!

7reactions
chetzofcommented, Feb 13, 2012

Please add semicolons, javascript already has some bad parts, don’t add even more.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript and semicolon - node.js - Stack Overflow
"use strict"[1,2,3,4]... and notes that this is valid javascript. Therefore a semicolon is not inserted since no "offending token" is found ...
Read more >
Strict mode - JavaScript - MDN Web Docs
JavaScript's strict mode is a way to opt in to a restricted variant of JavaScript, thereby implicitly opting-out of "sloppy mode".
Read more >
"use real strict" mode? - Ideas - TC39
I'm proposing a new feature where one could use "use real strict" instead of ... Many people (myself included) choose to code without...
Read more >
Syntax • JavaScript for impatient programmers (ES2022 edition)
7.8 Semicolons: best practices; 7.9 Strict mode vs. sloppy mode ... to avoid it – why is explained in §13.4.3 “Recommendation: always use...
Read more >
Semicolons in JavaScript - Flavio Copes
I personally like avoiding using semicolons in my code, but many people prefer them. ... Some prefer to use them always, no matter...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found