const state1 = "";
const state2 = "X";
!!state1 // false
!!state2 // true
Boolean(state1) // false
Boolean(state2) // true
🔗 What is the Double bang (!!) operator in JavaScript?
const adventurer = {
name: 'Alice',
cat: {
name: 'Dinah'
}
};
const dogName = adventurer.dog?.name;
console.log(dogName);
// expected output: undefined
console.log(adventurer.someNonExistentMethod?.());
// expected output: undefined
The ?. causes the expression to short-circuit (i.e. if the data to the left of ?. is undefined or null, it returns undefined and doesn’t evaluate the expression further).
🔗 How To Safely Work With Nested Objects in JavaScript
Flexbox가 기능을 말하는지, 프레임워크 같은 개념인지 정확한 정의가 궁금해서 찾아본 글. W3C CSS Flexbox(CSS Flexible Box Layout Module) 명세서 첫문단의 내용이다.
The specification describes a CSS box model optimized for user interface design. In the flex layout model, the children of a flex container can be laid out in any direction, and can “flex” their sizes, either growing to fill unused space or shrinking to avoid overflowing the parent. Both horizontal and vertical alignment of the children can be easily manipulated.
🔗 Flexbox is a framework?
🔗 CSS Flexible Box Layout Module Level1