Compare commits
No commits in common. "de877bd04ff28d52e59f1e0a4727c12d5f8f1f7a" and "f9cc8781ccce086d0a31ccb664d192d427cd987e" have entirely different histories.
de877bd04f
...
f9cc8781cc
@ -261,23 +261,16 @@ people("啦啦啦", 18)
|
|||||||
|
|
||||||
### 实现上面的题目
|
### 实现上面的题目
|
||||||
|
|
||||||
```javascript
|
|
||||||
var num = 100;
|
|
||||||
var shop = 80;
|
|
||||||
function buy(num,shop){
|
|
||||||
if(num - shop < 0 ){
|
|
||||||
alert("买不起")
|
|
||||||
}else{
|
|
||||||
var shengyu = num - buy
|
|
||||||
alert("可以购买,剩余" + shengyu)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buy(num,shop)
|
|
||||||
```
|
|
||||||
|
|
||||||
## 作业
|
|
||||||
- 创建一个对象 用alert 弹出它的所有属性
|
|
||||||
- 创建一个数组 用alert弹出他所有的元素
|
|
||||||
- 创建一个function 传入两个参数 弹出这两个参数相乘的结果
|
#### 循环语句
|
||||||
- 创建一个function 传入两个数 弹出最大的那个数
|
- for
|
||||||
|
- while
|
||||||
|
- do while
|
||||||
|
|
||||||
|
#### for
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
# 数据类型转换
|
|
||||||
|
|
||||||
## 显式类型转换
|
|
||||||
|
|
||||||
什么叫显示类型转换? 就是手动用代码转换的时候叫显示 先看一下如何转换
|
|
||||||
```javascript
|
|
||||||
var num = 8;
|
|
||||||
alert(typeof num);
|
|
||||||
num = String(num);
|
|
||||||
alert(typeof num);
|
|
||||||
```
|
|
||||||
创建的时候是number 使用String 转换之后就成了字符串 这就是显示转换
|
|
||||||
|
|
||||||
那么转化有哪几个呢?
|
|
||||||
- Strung
|
|
||||||
- Number
|
|
||||||
- Boolean
|
|
||||||
|
|
||||||
这三个 用法跟上面一样
|
|
||||||
### number
|
|
||||||
转换number的时候注意点
|
|
||||||
- 只有是数字开头的才会被转换
|
|
||||||
- 多个小数点之后会是nan
|
|
||||||
-
|
|
Loading…
x
Reference in New Issue
Block a user