Javascript – Boolean

Đối tượng Boolean đại diện cho hai giá trị, hoặc là “true” hoặc “false”. Nếu tham số giá trị bị bỏ qua hoặc là 0, -0, null, false, NaN, không xác định hoặc chuỗi trống (“”) thì đối tượng có giá trị ban đầu là false.

Cú pháp

Sử dụng cú pháp sau để tạo một đối tượng boolean.

var val = new Boolean(value);

Thuộc tính Boolean

Sr.No.Property & Description
1constructor Returns a reference to the Boolean function that created the object.
2prototype The prototype property allows you to add properties and methods to an object.

Phương thức Boolean

Dưới đây là danh sách các phương thức của đối tượng Boolean và mô tả của chúng.

Sr.No.Method & Description
1toSource() Returns a string containing the source of the Boolean object; you can use this string to create an equivalent object.
2toString() Returns a string of either “true” or “false” depending upon the value of the object.
3valueOf() Returns the primitive value of the Boolean object.