essentially, want use array list of arguments. however, function has argument called ranges: [ ], , list of specific ranges should go in there.
my code looks like:
var args = new array(); args.push({ color: '#c1f5b0', start: 0, length: 5 }) args.push({ color: '#c1f5b0', start: 6, length: 5 }) $('#demo').somefunc({ ranges: [ //list of objects goes here ] }); basically, want list of objects print args[0], args[1]. obviously, putting syntax args[0], args[1] range gives behaviour want. won't 2 elements in array. tried putting args.join() returns array contents string. using args in console.log(args) gives behaviour want, can't reproduce behaviour inside ranges: [ ] code.
before started, remember js lists , arrays same thing.
if want call function using array of arguments:
somefunc.apply($('#demo'), args); if want take part of args array:
somefunc({ranges: args.slice(0, 10)}); if want explode array arguments, es6:
somefunc({ranges: [...args]});
Comments
Post a Comment