Short Circuiting(&& and ||)
Use ANY data type, return ANY data type, short-circuiting
console.log('---- OR ----');
console. log(3 || 'Jonas');     //result:3
console.log('' || 'Jonas');     //result:Jonas
console.log(true || 0);         //result:true
console.log(undefined || null); //result:null

console.log(undefined || 0 || '' || 'Hello' || 23 || null); //result:Hello
console.log('---- AND ----');
console. log(0 && 'Jonas');     //result:0
console. log(7 && 'Jonas');     //result:Jonas

console.log('Hello' && 23 && null && 'Jonas'); //result:null
by გიორგი ბაკაშვილი
4 years ago
JavaScript
0
Pro tip: use ```triple backticks around text``` to write in code fences