Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
qianguyihao committed Aug 24, 2020
1 parent fc6cedd commit 7fe4ce0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions 04-JavaScript基础/07-typeof和数据类型转换.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ String(变量)

- 1.如果字符串中是纯数字,则直接将其转换为数字。

- 2.只要字符串中包含了非数字的内容(`小数点`按数字来算),则转换为 NaN。
- 2.如果字符串是一个空串或者是一个全是空格的字符串,则转换为 0

- 3.只要字符串中包含了其他非数字的内容(`小数点`按数字来算),则转换为 NaN。

- 3.如果字符串是一个空串或者是一个全是空格的字符串,则转换为 0

**情况二:布尔 --> 数字**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,13 @@ div.style.left = "100px";
setInterval(function () {
console.log(parseInt(div.style.left));
//动画原理: 盒子未来的位置 = 盒子现在的位置 + 步长;
//用style.left赋值,用offsetLeft获取值。
div.style.left = div.offsetLeft + 100 + "px";
//div.style.left = parseInt(div.style.left)+10+"px"; //NaN不能用
//方法1:用offsetLeft获取值,用style.left赋值。
div.style.left = div.offsetLeft + 100 + 'px';
// 方法2:必须一开始就在DOM节点上添加 style="left: 0px;"属性,才能用方法2。否则, div.style.left 的值为 NaN
// div.style.left = parseInt(div.style.left)+100+"px"; //方法2:
}, 500);
}
};
</script>
</body>
</html>
Expand Down
2 changes: 2 additions & 0 deletions 04-JavaScript基础/原型链.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@
注意,Object这个构造方法的显式原型是null,这是一个特例。


issues 101补充:通过原型链查找时,如果你找的是一个属性的话,则返回 undefined,如果你找的是一个方法,则报错。

## 常见题目

- 如何准确判断一个变量是数组类型
Expand Down

0 comments on commit 7fe4ce0

Please sign in to comment.