Skip to content Skip to sidebar Skip to footer

Expected "{" And Instead Saw "return"

Learning, cleaning up and updating a snippet I found on-line. I've been adding the somewhat new code 'use strict'; and the way the snippet has been programmed is alike the below sn

Solution 1:

Some automated tools consider placing a "naked" statement after a conditional (i.e. a statement not wrapped in a block) as bad practice.

Some even warn about multiple return statements or about writing if (x == 3) ... instead of if (3 == x) ....

The original statement if (!dragging) return; is perfectly valid Javascript. If it's more readable for you then just keep it that way and shut up that warning (there should be options to do that).

Post a Comment for "Expected "{" And Instead Saw "return""