arraysname-value

how can I use array in place of name value pair in a function


In the below code how can I use options array which is passed as a argument to drawOval

drawOval=function(options) {
    $triangle = new Triangle({
        // how can I use options array here
        // the format it accept is top:450,
        // left:500,width:200
    });
};
opt = new Array(
    top: 450,
    left: 500,
    width: 200,
    height: 200,
    fill: 'rgb(204,0,107)'
);
drawOval(opt);

Solution

  • Basically I need an object not array.

    opt= {
        top:100,
        left:200,
        width:200,
        height:200,
        fill:'rgb(12,0,107)'
    }
    drawOval(opt);