Truthy
if (123) { // Will be treated like `true`
console.log('Any number other than 0 is truthy');
}Booleanとして扱うことを明示的にする
// 値を他のものに移す
const hasName = !!name;
// オブジェクトのメンバとして利用する
const someObj = {
hasName: !!name
}
// 例: ReactJS JSX
{!!someName && <div>{someName}</div>}最終更新