Manipulação de Arrays

function execute() {

    var widgets = [];
    var object = [];

    for (let index = 0; index < 3; index++) {

        print('Index', index);
        var wid = {
            name: 'Ze ' + index,
            type: 'chat',
            id: index
        };

        print('Wid', wid);
        widgets.push(wid);
    }

    printWidget(widgets);

    var contact = widgets.shift();
    object['c0'] = contact;

    print('Object', object['c0']);
    printWidget(widgets);

    var contact = widgets.shift();
    object['c1'] = contact;

    print('Object', object['c1']);
    printWidget(widgets);

    widgets.push(object['c0']);
    widgets.push(object['c1']);

    print('Clear', 'Objeto restaurado');

    printWidget(widgets);

}

function print(type, obj) {
    console.log(type + '/> ');
    console.log(obj);
}

function printWidget(wids) {
    for (let index = 0; index < wids.length; index++) {
        print('==> Widget', wids[index]);
    }
}