zoukankan      html  css  js  c++  java
  • Object

    对象的定义,放出来有点无聊。就是从书上搬来而已,但是这样的定义却十分的明确。

    Object

      The simple types of JavaScript are numbers, strings, booleans (true and false), null, and undefined. All other values are objects. Numbers, strings, and booleans are object-like in that they have methods, but they are immutable(不可变). Objects in JavaScript are mutable keyed collections. In JavaScript, arrays are objects, functions are objects, regular expressions are objects, and, of course, objects are objects.

       An object is a container of properties, where a property has a name and a value. A property name can be any string, including the empty string. A property value can be any JavaScript value except for undefined.

       Objects in JavaScript are class-free. There is no constraint on the names of new properties or on the values of properties. Objects are useful for collecting and organizing data. Objects can contain other objects, so they can easily represent tree or graph structures.
       JavaScript includes a prototype linkage feature that allows one object to inherit the properties of another. When used well, this can reduce object initialization(初始化) time and memory consumption(耗损).

    Object Literals(对象字面量)

       Object literals provide a very convenient notation for creating new object values. An object literal is a pair of curly braces (花括号)surrounding zero or more name/value pairs. An object literal can appear anywhere an expression can appear:

    var empty_object = {};
    var stooge = {
        "first-name": "Jerome",
        "last-name": "Howard"
    };

       A property's name can be any string, including the empty string. The quotes around a property's name in an object literal are optional if the name would be a legal JavaScript name and not a reserved word (保留字). So quotes (引号)are required around "first-name", but are optional around first_name. Commas(逗号) are used to separate the pairs.

       A property's value can be obtained from any expression, including another object literal. Objects can nest(嵌套?):

    var flight = {
        airline: "Oceanic",
        number: 815,
        departure: {
            IATA: "SYD",
            time: "2004-09-22 14:55",
            city: "Sydney"
        },
        arrival: {
            IATA: "LAX",
            time: "2004-09-23 10:42",
            city: "Los Angeles"
        }
    };
    
  • 相关阅读:
    前端代码美化的艺术
    CSS3 简单的砸金蛋样式
    为什么 VS Code 能迅速占领 JavaScript 开发者社区
    了解并使用 CSS 中的 rem 单位
    CSS中一些利用伪类、伪元素和相邻元素选择器的技巧
    SVG入门指南
    PAT 1035 Password [字符串][简单]
    生信学习-二代测序知乎专栏总结[转]
    PAT 1119 Pre- and Post-order Traversals [二叉树遍历][难]
    生信笔记-mooc【武大】
  • 原文地址:https://www.cnblogs.com/coolicer/p/1853078.html
Copyright © 2011-2022 走看看