Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js nullish

const foo = null ?? 'default string';
console.log(foo);
// expected output: "default string"

const baz = 0 ?? 42;
console.log(baz);
// expected output: 0
Comment

javascript nullish

const nullValue = null;
const emptyText = ""; // falsy
const someNumber = 42;

const valA = nullValue ?? "default for A";
const valB = emptyText ?? "default for B";
const valC = someNumber ?? 0;

console.log(valA); // "default for A"
console.log(valB); // "" (as the empty string is not null or undefined)
console.log(valC); // 42
Comment

PREVIOUS NEXT
Code Example
Javascript :: useMutation on success function not being called 
Javascript :: pipefy api card search field 
Javascript :: vscode linux launch.json file cpp 
Javascript :: Codewars 1n- Cycle 
Javascript :: how to send post request js fetch 
Javascript :: how to get element position in jquery 
Javascript :: if else jquery click function 
Javascript :: width 100% react native 
Javascript :: jquery cdn google 
Javascript :: reactdom.render is no longer supported in react 18 
Javascript :: wait n seconds in js 
Javascript :: regex validate link 
Javascript :: add keyup event javascript 
Javascript :: windows 10 toast notifications nodejs 
Javascript :: useparams remix 
Javascript :: ajax redirect in success 
Javascript :: js random int 
Javascript :: how to change specific object in array javascript 
Javascript :: find unique elements in array javascript 
Javascript :: javascript set and get cookie 
Javascript :: jquery create input hidden 
Javascript :: implementating step component in react 
Javascript :: jquery clone 
Javascript :: ngcc failed angular 9 
Javascript :: split integer into digits javascript 
Javascript :: cannot use import statement outside a module from the console.log 
Javascript :: json object get field with at symbol 
Javascript :: isobject javascript 
Javascript :: javascript stringify an object 
Javascript :: react-native-checkbox in a loop 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =