前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

You Don't Know JS: this & Object Prototypes( 第3章 对象)的更多相关文章

  1. You Don't Know JS: this & Object Prototypes( 第5章 Prototypes)

    qu上章提到过[[prototype]] chain, 本章详细分析 ⚠️所有试图模仿类复制的行为,如上章提到的mixins的变种,完全规避了[[Prototype]] chain机制,本章会谈到这方 ...

  2. You Don't Know JS: this & Object Prototypes( 第4章 Mixing "Class" Objects)

    本章移到“Object oriented programming”和"classes". 看‘class orientation‘ 的设计模式: instantiation, in ...

  3. You Don't Know JS: this & Object Prototypes( 第2章 this)

    this is a binding made for each function invocation, based entirely on its call-site (how the functi ...

  4. You Don't Know JS: this & Object Prototypes( 第一章 this or That?)

    Foreword this 关键字和prototypes 他们是用JS编程的基础.没有他们创建复杂的JS程序是不可能的. 我敢说大量的web developers从没有建立过JS Object,仅仅对 ...

  5. You Don't Know JS: this & Object Prototypes (第6章 Behavior Delegation)附加的ES6 class未读

    本章深挖原型机制. [[Prototype]]比类更直接和简单! https://github.com/getify/You-Dont-Know-JS/blob/master/this%20%26%2 ...

  6. JS的Object漫想:从现象到“本质”

    转自:http://zzy603.iteye.com/blog/973649 写的挺好,用于记录,把对象分成概念的Object(var f={})和 类的Object(function F(){}) ...

  7. Javascript中Function,Object,Prototypes,__proto__等概念详解

    http://anykoro.sinaapp.com/2012/01/31/javascript%E4%B8%ADfunctionobjectprototypes__proto__%E7%AD%89% ...

  8. [JS] Topic - Object.create vs new

    故事背景 Ref: 你不知道的javascript之Object.create 和new区别 var Base = function () {} (1) var o1 = new Base(); (2 ...

  9. js 中object对象的操作

    n = object对象 for(var p in n){ console.log(p);// 取得是key值 console.log(n[p]);//取得是value值 } 继之前js中数组的常用方 ...

随机推荐

  1. Selenium Webdriver wait for JavaScript JQuery and Angular

    Hi all, during the last two weeks I was dealing with the best solution to wait for both JQuery, Angu ...

  2. Python3 tkinter基础 Entry validate validatecommand 失去焦点时,检查输入内容

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. 使用digitalocean进行项目开发

    使用digitalocean进行项目开发 命令记录 搭建SS 1 apt-get update 2 apt-get install python-pip 3 pip install --upgrade ...

  4. C# 选择文件、选择文件夹、打开文件(或者文件夹) 路径中获取文件全路径、目录、扩展名、文件名称 追加、拷贝、删除、移动文件、创建目录 修改文件名、文件夹名!!

    https://www.cnblogs.com/zhlziliaoku/p/5241097.html 1.选择文件用OpenDialog OpenFileDialog dialog = new Ope ...

  5. nginx 配置静态文件

    location /temp/ { root F:/; autoindex on; } F:\temp 下的目录文件. 例子:http://localhost/temp/nginx-1.12.2/ht ...

  6. 在Mac OSX下安装Microsoft Calibri字体

    参考: Where can I find default Microsoft fonts Calibri, Cambria? 在Mac OSX下安装Microsoft Calibri字体 1.下载: ...

  7. Leetcode122-Best Time to Buy and Sell Stock II-Easy

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  8. mac删除python

    删除Python框架 sudo rm -rf /Library/Frameworks/Python.framework/Versions/x.x 删除Python本程序 sudo rm -rf &qu ...

  9. 【Ruby】【改gem源镜像】【Win10 + Jruby-9.1.2.0 + Rails 5.1.3 + gem 2.6.4 】

    参考地址:https://ruby-china.org/topics/33843 (1)> gem sources --add http://gems.ruby-china.org 遇到问题: ...

  10. 【Java】【事件处理机制】

    import javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.Actio ...