<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
/*
4.函数 : 属于对象类型。
如何验证 :对象可以点语法动态赋值,如果函数也可以像对象一样使用点语法取值赋值,
就可以证明函数也是对象
*/
function fn(){
//存储代码
console.log('1111');
};
fn.aaa = '啊啊啊';
fn.eat = function(){
console.log('我中午请你吃饭');
};
fn.eat();
console.log(fn); // log:只能打印函数中存储的代码
console.dir(fn); // dir:打印函数对象内存
//查看 函数对象 的原型链
console.log(fn.__proto__.constructor);//Function
console.log(fn.__proto__ === Function.prototype);//true
//查看 函数对象 原型的原型
console.log(fn.__proto__.__proto__.constructor);//Object
console.log(fn.__proto__.__proto__ === Object.prototype);//true
</script>
</body>
</html>
03-函数也是对象
最新推荐文章于 2021-02-20 10:27:46 发布