diff --git a/5-JavaScript/class-02-operators/4-types.js b/5-JavaScript/class-02-operators/4-types.js index 45733e7b..8b595aae 100644 --- a/5-JavaScript/class-02-operators/4-types.js +++ b/5-JavaScript/class-02-operators/4-types.js @@ -43,3 +43,18 @@ console.log("0" ? "true" : "false"); console.log({} ? "true" : "false"); console.log(null ? "true" : "false"); console.log(-Infinity ? "true" : "false"); + +// Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing + +// Nullish Coalescing Operator +console.log("Emanuel" || "right-hand"); +console.log(1 || "right-hand"); + +console.log("" || "right-hand"); +console.log(0 || "right-hand"); + +console.log("" ?? "right-hand"); +console.log(0 ?? "right-hand"); + +console.log(null ?? "right-hand"); +console.log(undefined ?? "right-hand"); diff --git a/5-JavaScript/class-02-operators/index.html b/5-JavaScript/class-02-operators/index.html index 4f0fe28f..c367068c 100644 --- a/5-JavaScript/class-02-operators/index.html +++ b/5-JavaScript/class-02-operators/index.html @@ -5,9 +5,8 @@