<!DOCTYPE html>
<html>
<head>
    <title>ExtJs</title>
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  		<link rel="stylesheet" type="text/css" href="ExtJs/packages/ext-theme-crisp/build/resources/ext-theme-crisp-all.css">
      <script type="text/javascript" src="ExtJs/ext-all.js"></script>
      <script type="text/javascript" src="ExtJs/bootstrap.js"></script>
      <script type="text/javascript" src="ExtJs/packages/ext-theme-crisp/build/ext-theme-crisp.js"></script>
</head>
<body>
<script type="text/javascript">
  function Person(){
    this.name = 'hanzichi';
    this.age = 10;
  }
  var num = 0;
  for (var i in Person.prototype)
    num++;
  console.log(num);

  Person.prototype.show = function(){
    console.log(this.name);
  };
  Person.prototype.sex = 'male';

  var a = new Person();
  console.log(a.sex);
  a.show();
  console.log(a.__proto__ === Person.prototype);
  console.log(a.constructor === Person);
  console.log(Person.prototype.constructor === Person);

  console.log(Person.prototype);
  console.log(a);

  console.log('string'.constructor);
  console.log(new String('string').constructor);
  console.log(/hello/.constructor);
  console.log([1,2,3].constructor);
  function A() {}
  var a = new A()
  console.log(a.constructor);

  function Book(name){
    this.name = name;
  };
  Book.prototype.getName = function(){
    return this.name;
  };
  Book.prototype = {
    //constructor: Book,
    getPName: function(){
      return this.name;
    }
  };
  Book.prototype.constructor = Book;
  var b = new Book("ON THE WAY");

  console.log(b.constructor === Book);
  console.log(Book.prototype.constructor === Book);
  console.log(b.constructor.prototype.constructor == Book);
</script>
<body>
  <div id="tpl-table">
    <div>员工信息</div>
  </div>
</body>
</html>

  

实践一些js中的prototype, __proto__, constructor的更多相关文章

  1. js中的prototype和constructor

    本文正确性有待商榷,高手路过请不吝指教 1.js中只有对象,包括对象,函数,常量等. 对象不用解释.函数也有属性,常见之一就是prototype.常量也有属性: (3).__proto__;//Num ...

  2. js 中的 prototype 和 constructor

    var a=function(){ this.msg="aa"; } a.prototype.say=function(){ alert('this is say');} 1.只有 ...

  3. 帮你彻底搞懂JS中的prototype、__proto__与constructor(图解)

    作为一名前端工程师,必须搞懂JS中的prototype.__proto__与constructor属性,相信很多初学者对这些属性存在许多困惑,容易把它们混淆,本文旨在帮助大家理清它们之间的关系并彻底搞 ...

  4. JS中的prototype、__proto__与constructor属性

    作为一名前端工程师,必须搞懂JS中的prototype.__proto__与constructor属性,相信很多初学者对这些属性存在许多困惑,容易把它们混淆,本文旨在帮助大家理清它们之间的关系并彻底搞 ...

  5. JS中的prototype、__proto__与constructor

    1.前言 作为一名前端工程师,必须搞懂JS中的prototype.__proto__与constructor属性,相信很多初学者对这些属性存在许多困惑,容易把它们混淆,本文旨在帮助大家理清它们之间的关 ...

  6. JS中的prototype、__proto__与constructor(图解)

    作为一名前端工程师,必须搞懂JS中的prototype.__proto__与constructor属性,相信很多初学者对这些属性存在许多困惑,容易把它们混淆,本文旨在帮助大家理清它们之间的关系并彻底搞 ...

  7. Js中的prototype的用法一

    一 prototype介绍 prototype对象是实现面向对象的一个重要机制.每个函数也是一个对象,它们对应的类就是function,每个函数对象都具有一个子对象prototype.Prototyp ...

  8. 论js中的prototype

    今天在阅读代码时,碰到了prototype //判断是否是数组function isArray(obj) { return Object.prototype.toString.call(obj) == ...

  9. JS中对于prototype的理解

    JS中的prototype是JS中比较难理解的一个部分 本文基于下面几个知识点: 1 原型法设计模式 在.Net中可以使用clone()来实现原型法 原型法的主要思想是,现在有1个类A,我想要创建一个 ...

随机推荐

  1. 2749: [HAOI2012]外星人

    首先像我一样把柿子画出来或者看下hint 你就会发现其实是多了个p-1这样的东东 然后除非是2他们都是偶数,而2就直接到0了 算一下2出现的次数就好 #include<cstdio> #i ...

  2. Java-MyBatis:MyBatis

    ylbtech-Java-MyBatis:MyBatis 1.返回顶部 1. MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foun ...

  3. 713C

    费用流 并没有想出来构图方法 我们设立源汇,其实我们关心的是相邻两个值的差值,如果差值小于0说明需要长高,那么向汇点连边差值,说明需要修改,如果差大于零,那么由源点连边差值,说明可以提供修改空间,再由 ...

  4. fsockopen get,post 封装 (转)

    function http_request($url, $method = 'GET', $postfields = NULL, $headers = array()) {   $parse = pa ...

  5. PCB MongoDB数据库 备份与还原

    一. MongoDB数据库 备份与还原工具介绍: 数据备份工具  mongodump.exe 数据还原工具   mongorestore.exe 二. MongoDB数据库备份 mongodump - ...

  6. Check the difficulty of problems(概率+DP)

    http://poj.org/problem?id=2151 看的题解..表示没看懂状态转移方程.. #include<stdio.h> #include<string.h> ...

  7. bzoj1593 [Usaco2008 Feb]Hotel 旅馆(线段树)

    1593: [Usaco2008 Feb]Hotel 旅馆 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 758  Solved: 419[Submit ...

  8. Appium + python - swipe滑屏操作实例

    方法一: from appium import webdriverfrom time import sleep descred_caps = { "platformName":&q ...

  9. 使用 CSS 追踪用户

    原文地址:Crooked Style Sheets 作者:jbtronics 除了使用 JS 追踪用户,现在有人提出了还可以使用 CSS 进行网页追踪和分析,译者认为,这种方式更为 优雅,更为 简洁, ...

  10. Deutsch lernen (02)

    1. fließend a. 流利的 Meine französische Freundin spricht fließend Deutsch.     流动的 Der Verkehr wickelt ...