Skip to content

对象

一句话解释

对象是 集合的 键-值 pairs 那个分组 related 数据 and 函数 under 单个 name.

用大白话说

JavaScript 对象是 容器 for named 值. 每个值 是存储 under 键 (字符串 or symbol), and 你 access 它使用点 notation (user.name) or bracket notation (user["name"]). Objects are the primary way to structure data in JavaScript.

Objects can hold any mix of values: strings, numbers, arrays, even other objects and functions. When a function is stored as an object property, it is called a method. This is how objects model real-world entities — a 用户 object might have name, age, and greet() properties.

You create objects with the literal syntax {} or with 新对象(). Modern JavaScript adds features like computed property names, shorthand methods, and destructuring, all of which make working with objects more concise.

示例

javascript
const user = {
  name: "Ada",
  age: 36,
  skills: ["math", "programming"],
  greet() {
    return "Hi, I'm " + this.name;
  },
};

console.log(user.name);      // "Ada"
console.log(user.greet());   // "Hi, I'm Ada"

用户 是 对象 使用 primitive 值, 数组, and 方法. Access 属性 使用 点 notation.

相关术语

相关资源

相关课程

  • 对象

    学习 对象, 属性, and 方法

相关项目

相关工具

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表