fun.js let fun = function ( a, b, c, d) { let options = { a: 1, b: 'a', c: {}, d: function ( a, b, c) {} }; let isUndefined = o = typeof o == 'undefined'; let isFunction = o = typeof o == 'function'; let isNumber = o = typeof o == 'number';
let fun = function ( a, b, c, d) { let options = { a: 1, b: 'a', c: {}, d: function ( a, b, c) {} }; let isUndefined = o => typeof o == 'undefined'; let isFunction = o => typeof o == 'function'; let isNumber = o => typeof o == 'number'; let isString = o => typeof o == 'string'; let isObject = o => typeof o == 'object'; let setOptions = function ( o) { if ( isNumber( o)) { options.a = o; } else if ( isString( o)) { options.b = o; } else if ( isObject( o)) { options.c = o; } else if ( isFunction( o)) { options.d = o; } } for ( let obj of arguments) { setOptions( obj); } options.d( options.a, options.b, options.c); } fun( ( a, b, c) => { console.log( a, b, c); }, { list:[]}, 3, 'b');