Summary of front-end review (5)

Event handling mechanism process

Execute the initialization code, and then transfer the event callback function to the corresponding module for management. When the event occurs, the management module will add the callback function and its data to the callback queue for execution in turn, because js is single-threaded and must be initialized After the code is executed, the callback function in the callback queue will be read for execution

for…in和for…of

for...in traverses the key (traversal object)
for...of traverses the value

map()与forEach()

map gets a new array

let arr = [1, 2, 3, 4, 5];
let arr2 = arr.map(num => num * 2).filter(num => num > 5);
// arr2 = [6, 8, 10]

forEach changes the original array

Implement indexOf with native js

Insert picture description here
In addition to the note, there is also return, which will jump out of this function if this condition is met

The difference between = = and ===


=== Can convert type comparison value === Will judge value and type

Guess you like

Origin blog.csdn.net/weixin_46013619/article/details/104356362