前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. python ---16 初识面向对象

    面向对象 一 .面向对象和面向过程比较 ①面向过程:一切以事物的发展流程为核心    优点:负责的问题流程化,编写相对简单 缺点:可扩展性差 ②面向对象:一切以对象为中心. 一切皆为对象. 具体的某一 ...

  2. topcoder srm 380 div1

    problem1 link 分类讨论.高度没有太大关系.主要看长度. problem2 link 二分答案$mid$.计算每种$card$不足的部分,加起来,小于等于$min(jokers,mid)$ ...

  3. Python3 tkinter基础 Label imag显示图片

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

  4. [HEOI2016/TJOI2016]树

    [HEOI2016/TJOI2016]树 思路 做的时候也是糊里糊涂的 就是求最大值的线段树 错误 线段树写错了 #include <bits/stdc++.h> #define FOR( ...

  5. 带搜索框的jQuery下拉框插件

    由于下拉框的条数有几十个,于是打算找一个可以搜索查找功能的下拉框,刚开始在网上看了几个,都是有浏览器兼容性问题,后来看到这个“带搜索框的jQuery下拉框美化插件 searchable”,看演示代码简 ...

  6. POJ 2718 Smallest Difference(最小差)

     Smallest Difference(最小差) Time Limit: 1000MS    Memory Limit: 65536K Description - 题目描述 Given a numb ...

  7. 《Linux命令行与shell脚本编程大全》读书笔记

    第一章:初识Linux 1.linux可划分为四个部分:内核.GNU工具.图形化桌面环境.应用程序 2.内核主要负责:系统内存管理.软件程序管理.硬件设备管理.文件系统管理 3.内核的系统内存管理,有 ...

  8. python 读写json文件(dump, load),以及对json格式的数据处理(dumps, loads)

    JSON (JavaScript Object Notation) 是一种轻量级的数据交换格式.它基于ECMAScript的一个子集. 1.json.dumps()和json.loads()是json ...

  9. sqlserver 中常见的函数 数学函数

    create table testnum( ID int identity(1,1), num float) insert testnum values (1) insert testnum valu ...

  10. nodejs项目安装ant design

    1.确保安装好nodejs $ node --version v10.4.1 2.确保npm $ npm -v 6.1.0 3.安装 $ sudo npm install antd-init -g / ...