Js

alert()

alert object, need to JSON.stringify(object) first

otherwise, it shows

[object Object] 

this

函数是对象, 函数有属性和方法

call(), apply()预定义方法, 用于调用函数, 第一个参数必须是对象本身

function

  1. function declaration -> function object, can use properties, methods, and behavior of function objects
    can use before definition
  2. function expression -> can omit function name, create anonymenous function, but can not use before definition

  3. IIFE(Immediately Invoked Function Expression) -> create anonymenous function within grouping operator(), prevents accessing variables within IIFE idiom, second part create immediately executing function exoression() directly interpret function = immediately executed

play event and playing event

触发play event = (pause state=false) 但是不能确保真正在play
可能在任何一个时间 video没有足够的data ->pause state=false, 触发了waiting event 直到data又有(readyState >= have_future_data), 触发playing event 并且video重播
=> play 可以当做一个signal 作为视觉效果
=> playing 可以判断出是否真正在播放, 可以再waiting的时候 用loading icon表示等待

event listener

可以给element加as many as possible 的event -> element.addEventListener(event, function(){})
element onclick只有一个event,如果重新再写一个onclick event, 那么会把之前的overwrite -> element.onclick = function(){}

Commentaires

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×