3 ms·
"Const is not supported in IE [...] and wasn't originally supported in js." Which is an irrelevant point anyway since it still doesn't justify hijacking an alr
by TNO 17y ago
"Const is not supported in IE [...] and wasn't originally supported in js."
Which is an irrelevant point anyway since it still doesn't justify hijacking an already commonly accepted convention for some other purpose.
"In other words you can put () around the assignment, but that doesn't mean you should or that it's a best practice."
The point is that the meaning is clarified by using the convention.
"It is advisable to not use simple assignments in a conditional expression,..."
I would not presume to know what level of brevity is desirable for a developer in a given situation. Conventions like the one mentioned are available for clarification of such constructs.
"Crockford literally wrote the book on JavaScript, and I've seen his defense of some of his coding conventions in various talks, so I'm inclined to give him the benefit of the doubt."
Accepting an argument based on perceived authority is a logical fallacy. "the book on JavaScript" has some questionable things as well I hear:
Function.prototype.method = function(name, func) {
this.prototype[name] = func;
return this;
};
I do truly hope people don't consider such examples a good idea.