I think you may be missing something: both <!-- and --> are treated individually as // single line comments. They don't constitute a /* .. */ multi-line comment pair/block (like they do in HTML). Example:
var a = 2;
<!-- a = 3;
a = 4;
--> a = 5;
console.log(a); // 4
There's special rules around the --> token, that it has to be the first non-whitespace, non-multi-line-comment on a single line to be recognized as a comment delimiter. But otherwise, both act like a //.
----
As for doing a run-time check, I think it's quite possible you could construct such a check, but I think it would be moot, because AFAICT, all JS engines themselves do support this comment syntax. Chakra, Spidermonkey, JavaScriptCore, and v8 all do. Not sure about Rhino, but I've heard it does. Certainly any engine that remotely executes web focused content has to, for backwards compat.
Now, JS tools (like parsers, compilers, transpilers, minifiers, analyzers, etc…), those don't all support it. Up until this morning, I didn't know of any tools with support.
But Acorn and UglifyJS landed support this morning, and Esprima accepted the request and should land a patch at some point. Anton said that JSHint would accept a patch for it, but that he wouldn't write the patch. (however, JSHint is the only tool I've found that flat out breaks, throws an error and crashes, rather than reporting gracefully about the unsupported syntax, so given the more severity of their bug, I'd bet they have to fix one way or the other, and probably soon).
We could probably guess that Crockford won't land support in JSLint. I don't even want to ask him. BUT, perhaps after ES6 standardizes it, he will. Who knows?
But since only a JS engine actually executes at run-time, I think a run-time check for support wouldn't be fruitful, and would probably always return true. However, you COULD construct a check as to whether a piece of code was, at any point, processed by a tool that either did or didn't, and then perhaps I guess there's something you could do at run-time with the knowledge of your tooling stack. But again, this seems fairly niche/academic.
Given that several tools spoke up and agreed to start supporting these (because of the expected ES6 specification), I think all JS tools should seriously consider either automatic, or at least enabled with a config-flag, this kind of support.
If we have some tools with support and some without, that harms tool interop.
--Kyle
> You received this message because you are subscribed to a topic in the Google Groups "js-tools" group.
> To unsubscribe from this topic, visit
https://groups.google.com/d/topic/js-tools/kBJSzXOwSRU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
js-tools+u...@googlegroups.com.