Re:JavaScript for hackers
by thedufer on Tuesday January 07, 2014 @01:39PM
(#7018926)
>JavaScript doesn't know the result of a function until it is executed, and obviously it has to call the function to return the variable type.
> +alert(1)--
That's a particularly poor example. There's no reason to expect `alert` to run there (in current Chrome, it doesn't) - a function can't return an l-value, so you don't have to wait for the return value to determine that it'll be invalid.
Also, I'm not sure what the unary + is supposed to achieve - it has the same precedence as post-decrement, with right to left associativity, so knowing that the post-increment will fail shows us that the + will never run.
> +alert(1)--
That's a particularly poor example. There's no reason to expect `alert` to run there (in current Chrome, it doesn't) - a function can't return an l-value, so you don't have to wait for the return value to determine that it'll be invalid.
Also, I'm not sure what the unary + is supposed to achieve - it has the same precedence as post-decrement, with right to left associativity, so knowing that the post-increment will fail shows us that the + will never run.