javascript - How can I coerce a check for a variable being defined or not into a string reading True or False? -
i have console logs set this:
console.log("getteststatusactions" + this.userteststatusactions === undefined);
this gives output single word "false".
how can create output of be:
"getteststatusactions: userteststatusactions defined"
or
"getteststatusactions: userteststatusactions undefined"
ternary!
console.log("getteststatusactions" + (this.userteststatusactions === undefined ? "undefined" : "defined"));
or, readability:
var status = this.userteststatusactions === undefined ? "undefined" : "defined"; console.log("getteststatusactions: userteststatusactions " + status);
javascript
No comments:
Post a Comment