&& between 2 variables out of condition

I recently saw this piece of code on one of the scripts running on facebook:

__d("Shaka", [], function a(b, c, d, e, f, g) {
    c.__markCompiled && c.__markCompiled();
    var h = {};

For someone with C #, as the main background of development experience, I couldn't help but notice that the line c.__markCompiled && c.__markCompiled();looks weird as before. I did quite a bit of javascript coded, but the only place where I used &&was inside conditional expressions, such as ifs, for, whileetc. What does this operator do and what is the logic behind it?

+4
source share
2 answers

Line

c.__markCompiled && c.__markCompiled();

actually coincides with

if (c.__markCompiled) c.__markCompiled();

&& , (.. undefined, null, 0, "", NaN false).

+4

&& , if.

if &&, , false.

false && some_function();

true && some_function();

, , -

test_me() && call_if_true();

, :

if (test_me()) { call_if_true(); }

:

test1() && test2() && some_thing() && something_else();

, , false.

Javascript - ...

+1

All Articles