前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. repo回退当前分支下所有仓库到指定日期前的最新代码版本【转】

    本文转载自:https://blog.csdn.net/u011006622/article/details/70272087 执行下面这样的repo命令就行了:  repo forall -c 'c ...

  2. 【做题】arc080_f-Prime Flip——转换、数论及匹配

    题意:有一个无限序列,其中有\(n\)个位置上的数为\(1\),其余都是\(0\).你可以进行若干次操作,每次选取序列上的一个区间\([l,r)\),满足\(r-l\)为奇质数,将在这个区间上的数都异 ...

  3. 简单的栈溢出demo

    Code package startnow; /** * @auther draymonder */ public class StackOverFlowTest { public static vo ...

  4. cumtoj 一起来选课

    一起来选课 题目地址:http://192.168.173.163/JudgeOnline/problem.php?cid=1019&pid=7 题目 明泽私立大学有n门课程提供给大一的同学来 ...

  5. BZOJ2956: 模积和

    Description 求∑∑((n mod i)*(m mod j))其中1<=i<=n,1<=j<=m,i≠j. Input 第一行两个数n,m. Output 一个整数表 ...

  6. 4-Three-Matterhorn man

    What was the main objective of early mountain climbers?   ①Modern alpinists try to climb mountains b ...

  7. LightOJ 1258 Making Huge Palindromes(KMP)

    题意 给定一个字符串 \(S\) ,一次操作可以在这个字符串的右边增加任意一个字符.求操作之后的最短字符串,满足操作结束后的字符串是回文. \(1 \leq |S| \leq 10^6\) 思路 \( ...

  8. 自定义Exception——实战篇

    public class EntityConfigurationException : Exception { public EntityConfigurationException(string m ...

  9. EPPlus实战篇——Excel写入

    .net core 项目 可以向excel写入任何类型(T)的数据,只要T中的field的[Display(Name = "1233", Description = "# ...

  10. -第1章 HTMLCSS方法实现下拉菜单

    中英文的自动换行问题 把下面代码中的 javascript 改成 子菜单1 试试, 如果英文的话宽度会自动撑开, 用中文不会, 而直接转行下来. <ul> <li><a ...