Home > Net >  Array multidimensional javascript
Array multidimensional javascript

Time:12-16

this is my first post and i hope the comunity can help me. I want to create an array in javascript, i tried but i can't. this is the array in php, how i do this in javascript?

$structure = array(
            0 => array(
                'columns' => array(
                    array('tipo' => 'banner', 'data' => array('name' => '61b9f0845b7da.jpg'))
                )
            ),
            1 => array(
                'columns' => array(
                    array('tipo' => 'product', 'data' => array('id_product' => 1233198)), 
                    array('tipo' => 'product', 'data' => array('id_product' => 2021097, 'color' => '333'))
                )
            )`enter code here`
        );

CodePudding user response:

You want an array of objects.

[
    {
        columns: [{
            tipo: 'banner',
            data: {
                name: '61b9f0845b7da.jpg'
            }
        }]
    }, 
    {
        columns: [{
            tipo: 'product',
            data: {
                id_product: 1233198
            }
        }, {
            tipo: 'product',
            data: {
                id_product: 2021097,
                color: '333'
            }
        }]
    }
]
  • Related