View Single Post
Old 02-25-2013, 01:51 AM   PM User | #10
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,468
Thanks: 0
Thanked 499 Times in 491 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Just found the following example on the Mozilla web site:

Code:
var unboundSlice = Array.prototype.slice;
var slice = Function.prototype.call.bind(unboundSlice);
 
function list() {
  return slice(arguments);
}
 
var list1 = list(1, 2, 3); // [1, 2, 3]
So a more generic version of that could be:

Code:
var A = Function.prototype.call.bind(Array.prototype.slice); // only needed once
 
function x() {
args = A(arguments);
//code to use args as an array
}
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/

Last edited by felgall; 02-25-2013 at 04:37 AM..
felgall is offline   Reply With Quote