javascript double question mark
//Similar to || but only returns the right-hand operand if the left-hand is null or undefined
0 ?? "other" // 0
false ?? "other" // false
null ?? "other" // "other"
undefined ?? "other" // "other"let a = null;
const b = a ?? -1; // Same as b = ( a != null ? a : -1 );
console.log(b); // output: -1
//OR IF
let a = 9;
const b = a ?? -1;
console.log(b); // output: 9
//PS.,VERY CLOSE TO '||' OPERATION IN FUNCTION, BY NOT THE SAMEfunction config(options) {
options.duration ??= 100;
options.speed ??= 25;
return options;
}
config({ duration: 125 }); // { duration: 125, speed: 25 }
config({}); // { duration: 100, speed: 25 }
Also in JavaScript:
- console log nested objects js
- number of edges between set of nodes networkx
- html js drag image with mouse
- javascript multiple startswith
- daysinmonth javascript
- WHAT IS NODE IN DOM
- javascript getposts callback
- javascript close window
- updatable time js
- node list files in directory
- how to recognize an array in javascript
- js remove specific element from array
- react Spread Attributes conditionally
- get ip adress express
- react search bar
- Event Popover
- créer composant react
- node close rabbitmq connection
- cut string from string javascript
- javascript function convert bytes into mb
- js deep serialize url array
- javascript masking if input matches patter
- node load file
- cb() never called! npm ERR! This is an error with npm itself.