Clone array (AS3)


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var a:Array = [1, 2, 3, 4, 5];
  2. var b:Array;
  3.  
  4. //clone a:
  5. b = a.map(function(e:*, ...r):*{ return e });
  6.  
  7.  
  8. /*
  9. "...r" is a "rest" and stands for the two more arguments, the function in map(f:Function, target:Object = null) needs.
  10.  
  11. Full function would be: function (element:*, index:int, array:Array):*{return e};
  12. */

URL: http://www.badabam.de

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.