What's the point of the Boolean object?

前端 未结 9 1053
遥遥无期
遥遥无期 2020-12-09 15:28

I am reading through the Mozilla Manual on JavaScript, and I come to this point in my reading, Boolean object. I can\'t see a single use for them. What\'s their point? Why w

9条回答
  •  一整个雨季
    2020-12-09 15:53

    Boolean.prototype.bang = function() {
        return !this.valueOf();
    }
    
    true.bang(); // false
    

    Everything in JavaScript is an object. But at the same time we also have primitives. It's really confusing, just don't overthink it.

提交回复
热议问题