什么样的数据类型? [英] What kind of data type is?

查看:81
本文介绍了什么样的数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。


我是Javascript的新手,我找到了一些代码,就是这样:


var fruit =

{

''apple'':{''weight'':10,''cost'':9},

' 'peach'':{''weight'':19,''cost'':10}

}


有人可以告诉我是什么类型的数据类型是水果??

Hi everybody:

I''m new in Javascript, I found some code and there is this:

var fruit =
{
''apple'' : { ''weight'' : 10, ''cost'' : 9},
''peach'' : { ''weight'' : 19, ''cost'' : 10}
}

somebody can tell me what kind of data type is fruit??

推荐答案

>>大家好:
>>Hi everybody:
我是Javascript的新手,我发现了一些代码,并且有:
var fruit =
{
''apple'':{''重量'':10,''成本'':9},
''桃'':{''重量'':19,''成本'':10}
} 有人可以告诉我什么样的数据类型是水果??
I''m new in Javascript, I found some code and there is this: var fruit =
{
''apple'' : { ''weight'' : 10, ''cost'' : 9},
''peach'' : { ''weight'' : 19, ''cost'' : 10}
}
somebody can tell me what kind of data type is fruit??




你好gt,


水果是Object类型。更具体地说,这是一个对象文字。

它只是创建和初始化新对象的另一种方式。


你看到的代码就是创建一个具有属性的新对象

''apple''和''peach''。反过来,''apple''和''桃子,也有属性

''重量''和''成本''。


希望这个澄清。



Hi gtux,

fruit is of type Object. More specifically, this is an object literal.
It''s just another way of creating and initialize new objects.

The code that you see is creating a new Object with the properties
''apple'', and ''peach''. In turn, ''apple'' and ''peach, also have properties
''weight'' and ''cost''.

Hope this clarifies.


gtux写道:
gtux wrote:
var fruit =
{
'' apple'':{''weight'':10,''cost'':9},
''peach'':{''weight'':19,''cost'':10}
}

有人可以告诉我什么样的数据类型是水果??
var fruit =
{
''apple'' : { ''weight'' : 10, ''cost'' : 9},
''peach'' : { ''weight'' : 19, ''cost'' : 10}
}

somebody can tell me what kind of data type is fruit??




''fruit''是一个对象两个属性''apple''和''peach'',他们自己

每个具有两个属性的对象(''weight''和''cost'')。


此构造{/*...*/}被称为对象文字(或对象

初始化),即一个表达式,它创建一个对象并同时初始化

。它相当于:


var fruit = new Object(); //或var fruit = {};

fruit.apple = {''weight'':10,''cost'':9};

fruit.peach = {''weight'':19,''cost'':10};





var fruit = new Object( ); //或var fruit = {};

fruit.apple = new Object(); //或fruit.apple = {};

fruit.apple.weight = 10;

fruit.apple.cost = 9;

//等。


您可以在ECMAScript中了解有关对象文字的更多信息

规范,§11.1.5。

HTH,

是的。



''fruit'' is an object with two properties ''apple'' and ''peach'', themselves
objects with two properties each (''weight'' and ''cost'').

This construct "{/*...*/}" is called object literal (or object
initialiser), i.e an expression which creates an object and initialises
it at the same time. It is equivalent to:

var fruit=new Object(); // or var fruit={};
fruit.apple= { ''weight'' : 10, ''cost'' : 9};
fruit.peach= { ''weight'' : 19, ''cost'' : 10};

or

var fruit=new Object(); // or var fruit={};
fruit.apple=new Object(); // or fruit.apple={};
fruit.apple.weight=10;
fruit.apple.cost=9;
//etc.

You can read more about the object literal in the ECMAScript
specification, §11.1.5.
HTH,
Yep.






gtux wrote:
各位大家好:

我是Javascript的新手,我找到了一些代码就有了这个:

var fruit =
{
''peach'':{''weight'':19,''cost'' :10}
}
有人可以告诉我什么样的数据类型是水果??
Hi everybody:

I''m new in Javascript, I found some code and there is this:

var fruit =
{
''apple'' : { ''weight'' : 10, ''cost'' : 9},
''peach'' : { ''weight'' : 19, ''cost'' : 10}
}

somebody can tell me what kind of data type is fruit??




嵌套哈希表,又名地图表也称为联想数组(选择你喜欢的
)。



Nested Hash table, aka Map table aka Associative array (choose what you
like).


这篇关于什么样的数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆