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 :: window.open function 
Javascript :: tailwind rn yarn install 
Javascript :: environment variable to debug knex 
Javascript :: horizontal tabs in react js 
Javascript :: save js 
Javascript :: node http 
Javascript :: remove elements from map javascript 
Javascript :: Selectores de jQuery CSS básicos 
Javascript :: jquery elements which id doesnt contain string 
Javascript :: java script example 
Javascript :: react filter array 
Javascript :: Angular patchValue dynamically 
Javascript :: bubbling and capturing in javascript 
Javascript :: @viewchild in angular :use for take any refrerence of element 
Javascript :: ReactComponent 
Javascript :: replace specific values in array 
Javascript :: return observable from function angular 
Javascript :: vue-router beforeeach 
Javascript :: asynchronous function using function constructor 
Javascript :: random message in discord.js 
Javascript :: handle bar 
Javascript :: regex forms 
Javascript :: export multiple function in node js 
Javascript :: javascript clear an array 
Javascript :: sweetalert2 small icon 
Javascript :: react validation form 
Javascript :: 2 dimensional array index of element value 
Javascript :: for check status in ajax javascript 
Javascript :: remove string from outside array javascript 
Javascript :: react native layout 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =