# Can I return an object on which a function is applied?

I'm wondering if it is possible or if it is correct to proceed in such a way:

var initiate_shop = function(shop_navigation, shop_container_id, items_per_page) {
return $(shop_navigation).jPages({ containerID : shop_container_id, first : false, previous : false, next : false, last : false, midRange : 15, perPage : items_per_page, animation : "fadeInUp", links : "blank", keyBrowse : true, scrollBrowse : false, callback : function(pages){ current_page = pages.current; total_pages = pages.count; } }); };  If the above isn't correct what could be a better way to write it? ## 1 Answer Looks good to me, if you always want those 3 params and never want to send anything else. Otherwise, you could improve it by receiving the non-mandatory params in an options object: "use strict"; var initiate_shop = function(container_id, options) { var default_settings = { containerID : container_id, first : false, perPage : 5, '...' : '...', callback : function(pages){ current_page = pages.current; total_pages = pages.count; } }, settings =$.extend(default_settings, options);