Search⌘ K
AI Features

Discussion: Negative Gravity

Explore how double minus signs function in JavaScript subtraction expressions, how spacing affects evaluation, and why certain expressions result in errors due to the decrement operator. Understand these nuances to improve your code debugging and comprehension skills.

Verifying the output

Now, it’s time to execute the code and observe the output.

Javascript (babel-node-es2024)
console.log(7 - - 5);
console.log(7 - -5);
console.log(7- -5);
//console.log(7--5); // SyntaxError

Run the code twice: once, as it is, and then remove the comment // on line 4 and run the code again. ...

Understanding the output