Is there a better way to extend object with internal objects?

$.fn.bestShow = function(s) {
        var d = {
                width: 0,
                height: 0,
                order: "numeric",
                orderBy: "",
                animation: {
                        type: "fade",
                        delay: 5000,
                        speed: 2000,
                        overlay: false
                },
                controls:       {
                        numeric: 0,
                        next: false,
                        play: false,
                        stop: false,
                        prev: false
                }
        };

        o = $.extend({},d,s);

        if (typeof(s) != 'undefined') {
                if (typeof(s.animation) != 'undefined') o.animation = 
$.extend({},
d.animation, s.animation);
                if (typeof(s.controls) != 'undefined') o.controls = $.extend({},
d.controls, s.controls);
        }

Reply via email to