1. //1.几乎所有函数都有prototype属性,这个是个指针,指向原型对象;Function.prototype这个没有
  2. //2.所有对象中都有__proto__属性.(Object.prototype该属性的值为null)
  3. //几乎所有函数都有 prototype/__proto__属性
  4. //3.函数都是Function的实例(函数是通过Function创建出来的对象)
  5. //自定义函数,Function,Array,RegExp,String,Boolean,Number,Object都是函数,都是通过Function创建出来的
  6. //4.几乎所有函数都继承自:Function.prototype
  7. //函数.__proto__===Function.prototype(除了Function.prototype本身,他没有prototype属性)
  8. //Object.__proto__===Function.prototype
  9. //Function.__proto__===Function.prototype
  10. //5.String.prototype.__proto__===Object.prototype
  11. // Array.prototype.__proto__===Object.prototype
  12. // Number.prototype.__proto__===Object.prototype
  13. // RegExp.prototype.__proto__===Object.prototype
  14. // Function.prototype.__proto__===Object.prototype
 
 //构造函数  普通函数  只在于调用方式不同
//=>当成普通函数来调用
//1.,函数内部的this指向调用的对象(如果没有找到调用的对象,this指向window)
//2.函数的返回值由return语句决定,如果没有说明函数没有返回值(返回值是undefined)
var  p1 =Person("历程");
//=>当成构造函数来调用
//1.创建一个该构造函数的实例
//2.将构造函数内部this的值指向该实例
//3.执行函数体
//4.默认的函数值,该实例
  1. function fn(){
  2. returnthis;
  3. }
  4. var f3=new fn();
  5. console.log(f3);//fn
  6. //return {name:"张三"};
  7. //此时构造函数的返回值是一个对象就不再使用默认的返回值了,返回值就是当前的对象
  8. function fn2(){}
  9. var f2 =new fn2();
  10. console.log(fn2);//fn2的实例
  11. //如果没有返回值,会是默认的返回值
  12. //如果返回值是基本数据类型的话,还是会使用默认的返回值
 
var p2 = new Person("范冰冰")
 
//函数  对象在内存中的存储特点
//Object也是一个函数
//结合对象与函数的的内存结构图完整进行理解
//为什么Function.prototype是个函数呢?
//Function与Function.prototype之间的关系
 
  1. function fn(){}
  2. console.log(fn.constructor);//Function
  3. console.log(fn.__proto__===Function.prototype);//true
  4. console.log(Object.__proto__===Function.prototype);//true
  5. console.log(Function.prototype===fn.__proto__);//true
  6. console.log(Object.constructor);// Function
  7. console.log(fn.prototype.constructor);//fn
  8. console.log(Function.prototype.__proto__.constructor);// Object
 

 
 
 
 
 
  1. var arr=["hello","say","pic"];
  2. var str3;//undefined
  3. for(var i=0;i<arr.length;i++){
  4. str3+=arr[i];//如果一个变量str3声明了没有赋值会有默认的值undefined如果参与运算的话就会出问题
  5. //所以以后再声明变量之后要给初始化的值
  6. }
  7. console.log(str3);//undefinedhellosaypic
  8. console.log(undefined+"abc");//变为一个字符串undefined abc
 

最新文章

  1. POJ 1743 Musical Theme ——后缀数组
  2. GOLANG 变量
  3. SPSS数据分析—多维尺度分析
  4. 关于用Java实现二维码的生成
  5. 1445 送Q币
  6. 磁盘空间已满导致rabbitmq无法启动
  7. Android-Empty-Layout:展示不同类型的页面布局,用于视图是空的时候
  8. careercup-链表 2.5
  9. 用3种方法在 operator= 中处理“自我赋值”
  10. C++ Primer 随笔 Chapter 2 变量和基本类型
  11. mysql操作之二
  12. 【转】Android 带checkbox的listView 实现多选,全选,反选----解决checkbox错位问题
  13. PHP基础入门(一)
  14. MySQL查询缓存总结
  15. python 【pandas】读取excel、csv数据,提高索引速度
  16. H5端密码控件自动化测试
  17. selenium&#160;win7+selenium2.0+python环境搭建
  18. 使用libcurl作为Http client
  19. 2.2.5synchronized代码间的同步性
  20. POJ 2676 Sudoku (数独 DFS)

热门文章

  1. cs224d 作业 problem set3 (一) 实现Recursive Nerual Net Work 递归神经网络
  2. 1.0搭建 Node.js 开发环境
  3. JavaBean详解
  4. 爬虫(四)—— 使用pyecharts展示数据
  5. Spring Cloud服务安全连接
  6. JavaScript中的对象-创建对象的7种模式
  7. fragment中的onCreateView和onViewCreated的区别和
  8. WPF 从服务器下载文件
  9. 前端学习(二)css样式笔记(笔记)
  10. Vue 一些零零散散~