📜  将对象转换为布尔值 javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:20.111000             🧑  作者: Mango

代码示例2
// bool will be false if object is null, false, 0, etc.
// bool will be true if object is an array, object, non-zero number, etc.

// method 1
let bool = !!object;

// method 2
let bool = Boolean(object);