使用ES6实现该方法
const obj={a:1,b:2,c:3};
function foo(o,arr){
//请实现该方法
}
foo(obj,["a","c"]);
Element又继承自Node和EventTarget,可以查阅:DOM进阶之EventTarget,DOM进阶之Node。
属性
Element有非常多的属性。
attributes,classList,className,clientHeight,clientLeft,clientTop,clientWidth,Element.id,Element.innerHTML,localName,namespaceURI,outerHTML,prefix,scrollHeight,scrollTop,scrollWidth,tabName
方法
Element有非常多的方法
addEventListener,attachShadow,dispatchEvent,getAttribute,getAttributeNames,getBoundingClientRect,getElementsByClassName,getElementByTagName,hasAttributes,insertAdjacentElement,querySelector,querySelectorAll,removeAttribute,removeEventListener,scroll,scrollBy,scrollIntoView,scrollTo,setAttribute,toggleAttribute
事件
可以使用addEventListener添加事件。
cancel,error,scroll,select,show,whell copy,cut,paste compositioned,compositionstart,compositionupdate blur,focus,focusin,focusout fullscreenchange,fullscreenerror keydown,keypress,keyup auxclick,click,contextmenu,dbclick,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,moseup touchcancel,touchend,touchmove,touchstart
跳出循环
outer_loop:
for(i=0;i<5;i++) {
for(j=i+1;j<5;j++) {
break outer_loop;
}
alert(1);
}