单项选择题
function Animal(){}在Animal的原型上扩展一个type的属性,值为’动物’,扩展一个say的方法,用于打印type属性,正确的实现方法是()
A.Animal.prototype.type=”动物”;Animal.prototype.say=function(){console.log(this.type)});
B.Animal={type:”动物”,say:function(){console.log(this.type)}
C.Animal.prototype({type:”动物”,say:function(){console.log(this.type)})
D.以上说法都不正确
点击查看答案
相关考题
-
单项选择题
在list元素内部末尾添加元素,以下正确的是()
A.appendChild
B.appendChildren
C.insertAfter
D.insertBefore -
单项选择题
box.onclick = function() { setTimeout(function() { console.log(this) }) }以上代码运行结果为()
A.window
B.box
C.undefined
D.程序报错 -
单项选择题
每个构造函数都有()属性,指向它的原型
A._proto_
B.prototype
C.constructor
D.以上都不对
