Skip to content

You Don't Know JS: Types & Grammar - "What about &&" Code example not clear enough #948

Open
@oriprice

Description

@oriprice

In What about &&? section we have the following code.

function foo() {
    console.log( a );
}

var a = 42;

a && foo(); // 42

result in comment should indicate that foo was called. but in fact we would get same result of "42" if first operand had been called (like in || operator). i think results of a and foo() should be different to make the example be clearer.

for example:

function foo() {
    console.log("foo");
}

var a = 42;

a && foo(); // "foo"

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions