2
This commit is contained in:
parent
2ac1c5b5b9
commit
97a4f337d6
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
@ -102,13 +102,66 @@ function name(){
|
|||||||
- undefined
|
- undefined
|
||||||
- object
|
- object
|
||||||
|
|
||||||
|
### 检测数据类型
|
||||||
|
|
||||||
|
如何检测 javascript中有一个typeof
|
||||||
|
例如
|
||||||
|
```javascript
|
||||||
|
var name = "啦啦啦";
|
||||||
|
alert(typeof name);
|
||||||
|
```
|
||||||
|
|
||||||
|
![image-20201231104704137](2.javascript基础.assets/image-20201231104704137.png)
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var age = 18;
|
||||||
|
alert(typeof age);
|
||||||
|
```
|
||||||
|
![image-20201231104814391](2.javascript基础.assets/image-20201231104814391.png)
|
||||||
|
|
||||||
#### boolean
|
#### boolean
|
||||||
|
|
||||||
只有 true 和 false 两个值 一个是真 一个是 假 就是他是不是的意思
|
只有 true 和 false 两个值 一个是真 一个是 假 就是他是不是的意思
|
||||||
比如 1 + 1 = 2 正确 就是true
|
比如 1 + 1 = 2 正确 就是true
|
||||||
在比如 1+1 = 3 错误 所以是fasle
|
在比如 1+1 = 3 错误 所以是fasle
|
||||||
|
但是在javascript中 判断两个是否相等是 == 就是两个等于号 一个等号的时候是赋值
|
||||||
|
例如
|
||||||
|
```javascript
|
||||||
|
var bool = true;
|
||||||
|
alert(typeof bool);
|
||||||
|
|
||||||
|
alert(typeof (1+1==2));
|
||||||
|
```
|
||||||
|
这两个都会弹出
|
||||||
|
|
||||||
|
![image-20201231105243850](2.javascript基础.assets/image-20201231105243850.png)
|
||||||
|
|
||||||
|
|
||||||
|
#### function
|
||||||
|
|
||||||
|
就是定义的函数
|
||||||
|
```javascript
|
||||||
|
function hello(){
|
||||||
|
|
||||||
|
}
|
||||||
|
alert(typeof hello)
|
||||||
|
```
|
||||||
|
|
||||||
|
![image-20201231105424140](2.javascript基础.assets/image-20201231105424140.png)
|
||||||
|
|
||||||
|
#### undefined
|
||||||
|
|
||||||
|
所有创建没有赋值的变量或属性都是undefined undefined类型的值只有一个 就是undefined
|
||||||
|
例如
|
||||||
|
```javascript
|
||||||
|
var age;
|
||||||
|
alert(typeof age);
|
||||||
|
alert(typeof undefined);
|
||||||
|
```
|
||||||
|
|
||||||
|
![image-20201231105746998](2.javascript基础.assets/image-20201231105746998.png)
|
||||||
|
#### array 数组
|
||||||
|
虽然说是数组 但是内容不只能是数字
|
||||||
|
|
||||||
上节中说了数字之间的加法 字符串也可以相加 但是字符串的相加是直接拼接起来 字符串与数字相加也会将字符串与数字拼接起来 然后返回一个字符串 (类型后面会讲)
|
上节中说了数字之间的加法 字符串也可以相加 但是字符串的相加是直接拼接起来 字符串与数字相加也会将字符串与数字拼接起来 然后返回一个字符串 (类型后面会讲)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user