gpt4 book ai didi

javascript - 使用js对象值

转载 作者:行者123 更新时间:2023-12-03 12:05:08 25 4
gpt4 key购买 nike

嗨,我有这个 js 对象,我想将元素“价格”“保存”在数组中,这样我就可以操作它们。我怎样才能做到这一点?

$(function(){
$("#elastic_grid_demo").elastic_grid({
'filterEffect': 'scaleup', // moveup, scaleup, fallperspective, fly, flip, helix , popup
'hoverDirection': true,
'hoverDelay': 0,
'hoverInverse': false,
'expandingSpeed': 500,
'expandingHeight': 500,
'items' :
[
{
'price' : '10.95',
'title' : 'Azuki bean',
'description' : 'Swiss chard pumpkin bunya nuts maize plantain aubergine napa cabbage soko coriander sweet pepper water spinach winter purslane shallot tigernut lentil beetroot.Swiss chard pumpkin bunya nuts maize plantain aubergine napa cabbage.',
'thumbnail' : ['images/small/1.jpg', 'images/small/2.jpg', 'images/small/3.jpg', 'images/small/10.jpg', 'images/small/11.jpg'],
'large' : ['images/large/1.jpg', 'images/large/2.jpg', 'images/large/3.jpg', 'images/large/10.jpg', 'images/large/11.jpg'],
'button_list' :
[
{ 'title':'Demo', 'url' : 'http://porfolio.bonchen.net/' },
{ 'title':'Download', 'url':'http://porfolio.bonchen.net/'}
],
'tags' : ['Portrait']
}, /* ...more items*/

最佳答案

使用 Array.map (请参阅 MDN )从对象数组创建数组:

var prices = [yourArrayOfObjects].map(function(v) {return v.price;});

关于javascript - 使用js对象值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25218842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com