You Don't Know JS: this & Object Prototypes( 第3章 对象)
前2章探索了this绑定指向不同的对象需要函数引用的call-site。
但是什么是对象,为什么我们需要指向它们?
本章探索细节。
Syntax
the rules that describe how words and phrases are used in a computer language!
对象来源于两种forms
- declarative(literal) form:
- constructed from
var myObj = {
key: value
// ...
}; var myObj = new Object();
myObj.key = value;
2者的结果没有区别。
用constructed form来创建对象及其少见。 开发者总是使用literal form。就连内建对象也是这样。
Type
object是6种primary types之一。 (string, number, boolean, null, undefined, object)
⚠️, 不是everything in JavaScript is an object, 这句话在JavaScript中完全❌!
对象有复杂的子类型。 complex primitives。
- 函数是一种子类型,a callable object。不过和普通的对象使用方式是一样的。
- 数组Array也是一种子类型,有额外的行为。
- 普通对象是hash类型。是对象的主类型。
Build-in 对象
其他的对象子类型,都是内建对象。
从名字看他们似乎和他们的simple primitives counter-parts(副本)相关,但是:
他们的关系是很复杂的,下面会进行简短的探索。
- String
- Number
- Boolean
- Object
- Function
- Array
- Date
- RegExp
- Error
qu上章提到过[[prototype]] chain, 本章详细分析 ⚠️所有试图模仿类复制的行为,如上章提到的mixins的变种,完全规避了[[Prototype]] chain机制,本章会谈到这方 ... 本章移到“Object oriented programming”和"classes". 看‘class orientation‘ 的设计模式: instantiation, in ... this is a binding made for each function invocation, based entirely on its call-site (how the functi ... Foreword this 关键字和prototypes 他们是用JS编程的基础.没有他们创建复杂的JS程序是不可能的. 我敢说大量的web developers从没有建立过JS Object,仅仅对 ... 本章深挖原型机制. [[Prototype]]比类更直接和简单! https://github.com/getify/You-Dont-Know-JS/blob/master/this%20%26%2 ... 转自:http://zzy603.iteye.com/blog/973649 写的挺好,用于记录,把对象分成概念的Object(var f={})和 类的Object(function F(){}) ... http://anykoro.sinaapp.com/2012/01/31/javascript%E4%B8%ADfunctionobjectprototypes__proto__%E7%AD%89% ... 故事背景 Ref: 你不知道的javascript之Object.create 和new区别 var Base = function () {} (1) var o1 = new Base(); (2 ... n = object对象 for(var p in n){ console.log(p);// 取得是key值 console.log(n[p]);//取得是value值 } 继之前js中数组的常用方 ... Hi all, during the last two weeks I was dealing with the best solution to wait for both JQuery, Angu ... Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ... 使用digitalocean进行项目开发 命令记录 搭建SS 1 apt-get update 2 apt-get install python-pip 3 pip install --upgrade ... https://www.cnblogs.com/zhlziliaoku/p/5241097.html 1.选择文件用OpenDialog OpenFileDialog dialog = new Ope ... location /temp/ { root F:/; autoindex on; } F:\temp 下的目录文件. 例子:http://localhost/temp/nginx-1.12.2/ht ... 参考: Where can I find default Microsoft fonts Calibri, Cambria? 在Mac OSX下安装Microsoft Calibri字体 1.下载: ... Say you have an array for which the ith element is the price of a given stock on day i. Design an al ... 删除Python框架 sudo rm -rf /Library/Frameworks/Python.framework/Versions/x.x 删除Python本程序 sudo rm -rf &qu ... 参考地址:https://ruby-china.org/topics/33843 (1)> gem sources --add http://gems.ruby-china.org 遇到问题: ... import javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.Actio ...You Don't Know JS: this & Object Prototypes( 第3章 对象)的更多相关文章
随机推荐