在javascript中创建数组时出现问题
我下面有一个 JavaScript 代码。
bgCustom = { 'items':[], 'items_num':3, 'element':'#bg_custom_thumbs', 'next': '#bg_custom_next_thumb', 'prev': '#bg_custom_prev_thumb', 'width':165 };
//populate array
bgCustom.items = [["images/backgrounds/bear-ears_thumb.jpg", "bear-ears.jpg", "Bear-Hair"], ["images/backgrounds/blue-swirls_thumb.jpg", "blue-swirls.jpg", "WaterSmoke"]];
我如何动态创建 bgCustom.items 数组。意味着我想要一个数组列表
[['val1_1','val1_2','val1_3'],['val2_1','val2_2','val2_3']]
任何人都可以帮助我吗?
i have a javascript code below.
bgCustom = { 'items':[], 'items_num':3, 'element':'#bg_custom_thumbs', 'next': '#bg_custom_next_thumb', 'prev': '#bg_custom_prev_thumb', 'width':165 };
//populate array
bgCustom.items = [["images/backgrounds/bear-ears_thumb.jpg", "bear-ears.jpg", "Bear-Hair"], ["images/backgrounds/blue-swirls_thumb.jpg", "blue-swirls.jpg", "WaterSmoke"]];
ho do i create bgCustom.items array dynamic. means i want a array list
[['val1_1','val1_2','val1_3'],['val2_1','val2_2','val2_3']]
Can any body help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将数组添加到数组末尾:
您还可以在特定索引处分配数组。如果您使用超出当前大小的索引,数组将自动扩展:
You can add arrays to the end of the array:
You can also assign arrays at specific indexes. The array will automatically expand if you use an index outside the current size:
这应该可以让它变得更有活力。
That should work for making it a little more dynamic.