Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

double question mark javascript

Nullish coalescing operator (??)
returns its right-hand side operand when its left-hand side operand is null or undefined, 
and otherwise returns its left-hand side operand.
const foo = null ?? 'default string';
console.log(foo);
// expected output: "default string" because left hand side is null.

const baz = 0 ?? 42;
console.log(baz);
// expected output: 0 , because left hand side ( 0 )  is not null or undefinded.
Comment

double question mark javascript

//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"
Comment

javascript double question mark

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 SAME
Comment

double question mark javascript

b = a ?? -1
_____________
if(a != null){
	b = a;
}
else{
	b = -1;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript integer to binary 
Javascript :: pass data ino pug nodejs 
Javascript :: d3.js 
Javascript :: open new window in java script 
Javascript :: javascript copy object 
Javascript :: add two floating point numbers jquery 
Javascript :: leaflet add scale 
Javascript :: what is getter and setter in javascript 
Javascript :: concat js 
Javascript :: 100 day javascript challenge 
Javascript :: print in javascript 
Javascript :: error first line of nextjs file 
Javascript :: sort array based on multiple columns javascript 
Javascript :: moment.js format 
Javascript :: render partial in js.erb 
Javascript :: show and hide element in react 
Javascript :: return statement javascript 
Javascript :: javascript select audio device 
Javascript :: node js postgresql query 
Javascript :: django csrf failed ajax case 
Javascript :: create 2d array in javascript filled with 0 
Javascript :: can we fine a key with help of value in array of objects javascript 
Javascript :: google scripts urlfetchapp hearders and body 
Javascript :: how to get form all filed with properties in jquery 
Javascript :: lunix increae ram available to nodejs 
Javascript :: multiselect 
Javascript :: eleventy open browser automatically 
Javascript :: sending json data uing fetch is empty 
Javascript :: js variables 
Javascript :: primeng browseranimationsmodule 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =