การอ้างอิงบูลีน JavaScript
JavaScript บูลีน
บูลีน JavaScript สามารถมีค่าใดค่าหนึ่งจากสองค่า: true
หรือ
false
.
ฟังก์ชันบูลีน ()
คุณสามารถใช้Boolean()
ฟังก์ชันเพื่อค้นหาว่านิพจน์เป็นจริงหรือไม่:
ตัวอย่าง
Boolean(10 > 9)
หรือง่ายยิ่งขึ้น:
ตัวอย่าง
(10 > 9)
10 > 9
สำหรับบทแนะนำเกี่ยวกับบูลีน โปรดอ่าน บทแนะนำบูลี นJavaScript ของเรา
จาวาสคริปต์บูลีนเมธอด
Method | Description |
---|---|
toString() | Converts a boolean value to a string, and returns the result |
valueOf() | Returns the primitive value of a boolean |
คุณสมบัติบูลีน JavaScript
Property | Description |
---|---|
constructor | Returns the function that created JavaScript's Boolean prototype |
prototype | Allows you to add properties and methods to the Boolean prototype |