<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>06_面试题</title>
</head>
<body>
<script type="text/javascript">
/*
测试题1
*/
function A () {
}
A.prototype.n = 1
var b = new A()
A.prototype = {
n: 2,
m: 3
}
var c = new A()
console.log(b.n, b.m, c.n, c.m)
/*
测试题2
*/
function F (){}
Object.prototype.a = function(){
console.log('a()')
}
Function.prototype.b = function(){
console.log('b()')
}
var f = new F()
// f.a()
// f.b() //报错
F.a()
F.b() //相当实例对象
console.log(f)
console.log(Object.prototype)
console.log(Function.prototype)
</script>
</body>
</html>
原型面试题
最新推荐文章于 2024-04-07 12:30:02 发布