mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-29 14:36:22 +00:00
40 lines
887 B
Markdown
40 lines
887 B
Markdown
|
---
|
||
|
id: 19822398-201e-426a-86f0-48ef5a09acda
|
||
|
title: JavaScript Booleans
|
||
|
---
|
||
|
|
||
|
# Syntax
|
||
|
|
||
|
``` javascript
|
||
|
console.log(3 > 2)
|
||
|
console.log(3 < 2)
|
||
|
```
|
||
|
|
||
|
Strings can also be compared
|
||
|
|
||
|
``` javascript
|
||
|
console.log("Aardvark" < "Zoroaster")
|
||
|
```
|
||
|
|
||
|
Uppercase characters are always less than lower case characters, so "Z"
|
||
|
\< "a". Non alphabetic characters are less than alphabetic characters
|
||
|
|
||
|
``` javascript
|
||
|
console.log("Zebra" < "aardvark")
|
||
|
console.log("!" < "aardvark")
|
||
|
console.log("!" < "Zebra")
|
||
|
console.log("3" < "Zebra")
|
||
|
console.log("!" < "3")
|
||
|
```
|
||
|
|
||
|
## Empty values
|
||
|
|
||
|
There are two special empty values, null & undefined that denote the
|
||
|
absence of any meaningful value. They can be used interchangeably and
|
||
|
are an [accident of JavaScripts
|
||
|
design](https://medium.com/@stephenthecurt/a-brief-history-of-null-and-undefined-in-javascript-c283caab662e).
|
||
|
|
||
|
``` javascript
|
||
|
console.log(null == undefined);
|
||
|
```
|