295 const board = currentBoard();
296 if(board === "") return; // not on a board
297 getThreadCooldown(board).then(cd => threadCooldown = cd);
298 getReplyCooldown(board).then(cd => replyCooldown = cd);299});
294$(() => {
295 const board = currentBoard();
296 if(board === "") return; // not on a board
297 getThreadCooldown(board).then(cd => threadCooldown = cd);298 getReplyCooldown(board).then(cd => replyCooldown = cd);
299});
One of the interesting, and sometimes confusing, aspects of JavaScript is that assignment can happen at almost any point. Because of this, an errant equals sign can end up causing assignment when the true intent was to do a comparison. This is especially true when using a return statement. For example:
function doSomething() {
return foo = bar + 2;
}
It is difficult to tell the intent of the return
statement here.
It's possible that the function is meant to return the result of bar + 2
, but then why is it assigning to foo
?
It's also possible that the intent was to use a comparison operator such as ==
and that this code is an error.
Because of this ambiguity, it's considered a best practice to not use assignment in return
statements.
function doSomething() {
return foo = bar + 2;
}
function doSomething() {
return foo += 2;
}
function doSomething() {
return foo == bar + 2;
}
function doSomething() {
return foo === bar + 2;
}
function doSomething() {
return (foo = bar + 2);
}