小知识汇总

查看一个变量名是不是存在 直接输入的话会提示错误,可以挂到window上以对象的方式查看

console.log(value)    //报错
consolelog(window.value)    //undefined

JS获取尺寸

clientWidth = width + padding
offsetHeight = width + padding + border
offset比client多了border的宽度 clientHeight offsetWidth 同理
getBoundingClientRect
详情

你可能感兴趣的:(小知识汇总)