- 博客(3)
- 收藏
- 关注
原创 实现继承的两种方法
已经定义了一个Animal类,要求定义一个People类继承Animal类的属性和方法function Animal(name,age){ this.name=name; this.age=age}Animal.prototype.intr=function(){console.log(`I'm ${this.name},I'm ${this.age}`)}解决方法:ES5:function People(name,age,classname){ Ani
2022-04-07 22:10:44
94
原创 笔试题:定义一个函数遍历一个指定父元素下的所有后代元素(深度优先遍历算法)
function getChildren(parent){ var children=parent.children; for(var child of children){ console.log(child.nodename)//元素的标签名 if(child.children.length>0){//如果child的下级有直接子元素就对child继续调用getChildren argument.callee(ch.
2022-04-07 21:31:58
152
原创 JS 判断对象obj1是不是数组的7种方法
//判断爹 prototype 三种1. obj1.__proto__==Array.prototype2. Object.getPrototypeOf(obj1)==Array.prototype3. Array.prototype.isPrototypeOf(obj1)//判断妈妈constructor 两种1. obj1.constructor==Array //通过原型链调用prototype的constructor 属性2.obj1...
2022-04-03 19:19:21
267
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅