本文介绍了对象和哈希之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaScript中,对象和哈希之间有什么区别?您如何创建一个与另一个,又为什么要关心呢?以下代码示例之间有区别吗?

In JavaScript, what is the difference between an object and a hash? How do you create one vs the other, and why would you care? Is there a difference between the following code examples?

var kid = {
 name: "juni",
 age: 1
}

并且:

var kid = new Object();
kid.name = "juni";
kid.age = 1;

并且:

var kid = new Object();
kid["name"] = "juni";
kid["age"] = 1;

您能想到我还要说明的任何其他代码示例吗?

Can you think of any other code example I should illustrate?

这里的核心问题对象和哈希之间的区别是什么?

推荐答案

根本没有.这三个词在字面上都是相等的.

There just isn't any. All three of those are literally equal.

这篇关于对象和哈希之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 15:17