Interview
二月 10, 2018
Prepare for daocloud
for...in&for...of&forEach
all of them above are used to traverse Object/Array. But these are some difference.
- can’t use
breakorcontinueinforEachto jump out loop even if you usereturn. since it does not support.
for…in(use for Object normally)
- index of Array is type of
Number. But index will change and becomestringin for…in syntax - in some case,
for...intraverse key without sequence.
- index of Array is type of
for…of(use for Array)
- can work with
break,continue,return - cant use for Object
- use for any structure as long as it have iteration interface
- can work with
debounce & throttle
1 | // debounce |
scroll overflow(称为滚动溢出,页面的某块滚动到底后再滚动也不带动整个页面滚动)
1 | function preventScroll(id) { |