A Boolean.

Boolean is a reference type that corresponds to a Boolean value. If we need to create a Boolean object (note: it is an object), we know that the new operator returns a new object instance in the constructor execution, so we can use its constructor, passing in true or false, as shown below

let booleanObj = new Boolean(true);
Copy the code

Let’s print out booleanObj on the console

Finding that it prints an object instead of a literal true, here’s an example of what the result will be.

let booleanObj = new Boolean(false);
let result = booleanObj && true;
console.log(result)
Copy the code

We see that the output is true, and without prior preparation, many people would think that the output is false, which is a point of misunderstanding. Because we use the constructor to create an object, that is, booleanObj stores an address. It then implicitly converts to true during comparison, and the result is true. Look at another example and you’ll see

let booleanObj = new Boolean(false);
let bol = true;
console.log(typeof booleanObj );//Object
console.log(typeof bol);//Boolean
console.log(booleanObj instanceof Boolean);//true
console.log(bol instanceof Boolean);//false
Copy the code

The second Number.

Let num = new Number(10) {Number {10}; But we can use valueOf() to get the literal valueOf the object, which is 10