Q:

Shortening javascript code with extend or etc

I have a function like that:
initGrid: function(tableGridId, url) {
        var deviceTableGridId;
        if (typeof tableGridId != "undefined"){
            deviceTableGridId = tableGridId;
        } else {
            deviceTableGridId = gridId;
        }
        var getUrl;
        if (typeof url != "undefined"){
            getUrl = url;
        } else {
            getUrl = restUrl;
        } 
..
} 

How can I write that code shorter? I mean with extend or etc.?

A:

    var deviceTableGridId = tableGridId || gridId,
        getUrl = url || restUrl;

