Object JavaScript内部的数组
Arrays inside of Object JavaScript
我想在对象内部创建一个数组,其值引用包含该数组的同一对象的属性。
我遇到的唯一问题是数组内部的结果没有定义,而不是它们应该是什么
我引用的属性是否正确?这是我为该对象编写的JavaScript。
var cc_cd = {
name: "CC Waterbound",
date: "Summer 1995",
t1name: "Intro",
t1url: "https://www.youtube.com/embed/Rsh5oQ6JCTI",
t1length: "0:40",
t2name: "Bout 2 Go Down",
t2url: "https://www.youtube.com/embed/XgJ6DdIaXd0",
t2length: "4:44",
t3name: "Dope and money",
t3url: "https://www.youtube.com/embed/cruY77l99_M",
t3length: "3:51",
t4name: "Looking Down the Barrel",
t4url: "https://www.youtube.com/embed/jmLgcnUlgfk",
t4length: "4:33",
t5name: "Playa Hatas",
t5url: "https://www.youtube.com/embed/ZY8eCUuuqJY",
t5length: "5:18",
t6name: "4 Real Nigga Possie",
t6url: "https://www.youtube.com/embed/A-syQCa3iN0",
t6length: "6:14",
t7name: "CC Waaterbound",
t7url: "https://www.youtube.com/embed/eIAOcKg8xfk",
t7length: "5:25",
t8name: "Creepin",
t9url: "https://www.youtube.com/embed/MpBB7rnaw_Q",
t9length: "3:56",
t10name: "Hood Cord",
t10url: "https://www.youtube.com/embed/PNMiP67NhcM",
t10length: "4:11",
t11name: "All This Dick",
t11url: "https://www.youtube.com/embed/a5zWyURBIjE",
t11length: "5:25",
array:[this.t1name,this.t1date,this.t1url,this.t2name,this.t2date,this.t2url,this.t3name,this.t3date,this.t3url,this.t4name,this.t4date,this.t4url,this.t5name,this.t5date,this.t5url,this.t6name,this.t6date,this.t6url,this.t7name,this.t7date,this.t7url,this.t8name,this.t8date,this.t8url,this.t9name,this.t9date,this.t9url,this.t10name,this.t10date,this.t10url,this.t11name,this.t11date,this.t11url]
}
我不知道可能出了什么问题,但我知道一个简单的解决方案可以是创建一个全局数组,然后将属性设置为全局数组。代码:
var array = [ your array] ;
var cc_cd = {
List : array,
Other properties
};
请标记答案或投票让我知道这是否有帮助!
相关文章:
- 访问JSON对象内部的数组元素
- 将当前用户的 ID 推送到 meteorjs 中集合/文档的内部数组
- 正在更新mongod中两个对象内部的数组
- 如何在循环数组内部推送变量值
- 在Javascript数组内部调用URL变量
- 如何在Mongoose中从多个数组更新数组内部的值
- 创建带有回调的动态 JSON 数组(内部闭包问题)
- 循环数组内部和数组
- 如何为自定义jQuery函数制作数组内部的数组数据
- 数组内部的Javascript数组-如何调用子数组名称
- 有没有一种方法可以将一个元素从二维数组内部移动到数组中的另一个位置,而不移动其他元素?
- 在数组内部迭代数组
- JSON -需要javascript数组内部的数组和编码JSON
- 检查数组是否在数组内部
- 试图通过Json对象,有更多的对象与对象数组内部循环
- 按数组内部值过滤数组
- 是否可以在数组内部和数组之间来回移动对象
- 当数组内部的某个可观察数组项发生更改时,更新父挖空可观察数组项
- 为什么for.in()循环不返回数组内部的对象
- 不能修改原型数组内部