From 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:43:23 -0500 Subject: initial commit --- files/vi/tu-dien-thuat-ngu/falsy/index.html | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 files/vi/tu-dien-thuat-ngu/falsy/index.html (limited to 'files/vi/tu-dien-thuat-ngu/falsy/index.html') diff --git a/files/vi/tu-dien-thuat-ngu/falsy/index.html b/files/vi/tu-dien-thuat-ngu/falsy/index.html new file mode 100644 index 0000000000..c71e9cc197 --- /dev/null +++ b/files/vi/tu-dien-thuat-ngu/falsy/index.html @@ -0,0 +1,32 @@ +--- +title: Falsy +slug: Tu-dien-thuat-ngu/Falsy +translation_of: Glossary/Falsy +--- +

Giá trị falsy là giá trị được hiểu là false trong ngữ cảnh {{Glossary("Boolean")}}.

+ +

{{Glossary("JavaScript")}} sử dụng {{Glossary("Type_Conversion", "Type Conversion")}} để ép kiểu giá trị bất kì thành Boolean khi cần thiết, ví dụ trong mệnh đề điều kiện ({{Glossary("Conditional", "conditionals")}}) và vòng lặp ({{Glossary("Loop", "loops")}}).

+ +

Ví dụ

+ +

Sau đây là ví dụ về các giá trị falsy (sẽ được hiểu là 'false' dẫn đến không thực hiện đoạn code của if ):

+ +
if (false)
+if (null)
+if (undefined)
+if (0)
+if (NaN)
+if ('')
+if ("")
+if (document.all) [1]
+ +

[1] document.all trước đây được sử dụng trong việc nhận biết trình duyệt và tài liệu HTML specification defines a willful violation của chuẩn ECMAScript này để tương thích với code cũ (if (document.all) { // Internet Explorer code here } hoặc sử dụng document.all mà không kiểm tra trước về sự tồn tại của nó: document.all.foo).

+ +

Đôi khi từ này được viết là falsey.

+ +

Tìm hiểu thêm

+ + -- cgit v1.2.3-54-g00ecf