Skip to content

Commit 622978b

Browse files
authored
nullish coalescing operator
1 parent ad8e0c8 commit 622978b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,19 @@ window.addEventListener('contextmenu', ()=>{
374374
//With defer, browser will run your script when the page finished parsing. (not necessary finishing downloading all image files.
375375
<script defer src="myscript.js"></script>
376376
```
377+
378+
# nullish coalescing operator
379+
```javascript
380+
381+
// an equality check against nullary values (e.g. null or undefined). Whenever the expression to the left of the ?? operator evaluates to either //undefined or null, the value defined to the right will be returned.
382+
383+
const foo = undefined ?? 'default string';
384+
console.log(foo);
385+
// expected output: "default string"
386+
387+
388+
const age = 0 ?? 30;
389+
console.log(age);
390+
// expected output: "0"
391+
```
392+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy