+
Skip to content

Stupid(?) question #51

Closed
Closed
@dctr

Description

@dctr

Hi everyone. I only do JS for a couple of weeks now and could not find out, why the code

  this.show = function(username, cb) {
    var command = username ? "/users/"+username : "/user";

    _request("GET", command, null, function(err, res) {
      cb(err, res);
    });
  };

Works with

  ....show('dctr', myFunc);

and with

  ....show(myFunc);

Why doesn't command evaluate to something absurd and cb fails but myFunc is called in both cases? At least i would have expected something like

  cb = username ? cb : username;

Thanks in advance for anwers...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载