(1)slice()与substring(start,stop)的区别
都用于提取字符串中介于两个指定下标之间的字符,substring()不接受下标为负数,如果参数 start 与 stop 相等,那么该方法返回的就是一个空串(即长度为 0 的字符串)。如果 start 比 stop 大,那么该方法在提取子串之前会先交换这两个参数,结果不包括stop
![](https://img.haomeiwen.com/i3213965/efd37a51c74dadc4.png)
substring原则上不接受负数,当强行传入负数,则会当作0处理,并对传入的参数进行正序排列,再进行截取
![](https://img.haomeiwen.com/i3213965/4f6ed202d6f7d327.png)
不提倡使用substr( start, length),不是ECMAscript标准
(2)onfocus
onfocus 事件在对象获得焦点时发生。
Onfocus 通常用于 <input>, <select>, 和<a>
(4)lastIndexOf()
![](https://img.haomeiwen.com/i3213965/c06afd361fff260a.png)
(5)在数组长度外进行赋值,会以赋值处长度作为数组长度,前面的全部填充为undefined
![](https://img.haomeiwen.com/i3213965/3bba09965e0adca7.png)
var arr =[1,2,3,4];
arr[10] = 10;
console.log(arr.length); //11
(6)为类数组对象设置样式,需要进行遍历或单独选中
![](https://img.haomeiwen.com/i3213965/143043ed7b05adea.png)
(7)domReady
给还未解析到的dom元素绑定事件会报错,应该加上onload事件
![](https://img.haomeiwen.com/i3213965/0d999593f8bb54de.png)
html元素可以内联绑定多个事件
(8)confirm对话框
![](https://img.haomeiwen.com/i3213965/0f3d132e168e4249.png)
(9)清除浮动
![](https://img.haomeiwen.com/i3213965/caa73557f57bb385.png)
(10)冒泡与捕获流程
![](https://img.haomeiwen.com/i3213965/3d5775060bd8ac80.png)
![](https://img.haomeiwen.com/i3213965/04093f5531b29fd2.png)
(11)关于遍历数组找出匹配项进行操作
- 直接进行for循环
- Array.indexOf()
- Array.forEach() 不能返回值
Array.include(target)
![](https://img.haomeiwen.com/i3213965/bad48471e8d8e94d.png)
(12)undefined,null转字符串
![](https://img.haomeiwen.com/i3213965/19ab88baa7b98c5f.png)
(13)数组map方法必须得有返回值
(14)判断是否是IE浏览器
![](https://img.haomeiwen.com/i3213965/1dce5a23cff6b2a8.png)
网友评论