javascript linting error
Posted: Fri Jun 12, 2015 4:01 pm
I have a piece of code below that says "Unexpected assignment expression." where (foo = bar).
function bar() {}
var foo;
foo || (foo = bar);
I have tried to create a variable before it and assign it to the variable. But it gives another error where foo is saying "Expected an assignment or function call and instead saw an expression." where foo || foobar (foobar is the variable i had to create when i tried var foobar = bar) (basically foo || foobar). I keep running into a wall trying to figure this one out. How would you recode this lint free?
Thanks.
function bar() {}
var foo;
foo || (foo = bar);
I have tried to create a variable before it and assign it to the variable. But it gives another error where foo is saying "Expected an assignment or function call and instead saw an expression." where foo || foobar (foobar is the variable i had to create when i tried var foobar = bar) (basically foo || foobar). I keep running into a wall trying to figure this one out. How would you recode this lint free?
Thanks.