---
title: "JS-Boolean"
author: "mingren135"
date: "2013-03-21T22:56:23Z"
tags: []
categories: ["Web前端"]
slug: "js-boolean"
draft: false
lastmod: "2013-03-21T22:56:23Z"
id: 1833779
url: "https://mingren135.iteye.com/blog/1833779"
---

**Boolean Values**

The following values convert to and therefore work like false:  
**![](http://dl.iteye.com/upload/attachment/0082/0054/9aecd8d7-0793-36f5-bb6d-6c6e093f2f55.jpg)**  
 All other values,including all objects(and arrays) convert to and work like true.

You can test explicitly to see if a is non-null with an if statement like this

```
if(a!==null)...
```

 and you can test to see if a is falsy or truthy value

```
if(a)...
```

 In the first case, the body of the if will be executed only if a is not null.The second case if less strict:it will execute the body of the if only if a is not false or any falsy value.