Permalink
Browse files

way better swap function - now works in-place on objects and arrays (…

…primitives are always pass by value so they will never work)
  • Loading branch information...
Ilink committed Apr 22, 2012
1 parent 91f825c commit 51508738649880f0cf0761ff3bc43284c559d4fb
Showing with 1 addition and 5 deletions.
  1. +1 −5 util.js
View
@@ -5,11 +5,7 @@ var Util = function(){};
objects and arrays muat have the same number of elements / properties
objects must have the same property names
- Usage:
-
- a = 1; b = 2;
- result = swap(a,b);
- a = result[0]; b = result[1];
+ numbers cannot be swaped in-place since they are never passed by reference
*/
Util.prototype.swap = function(a, b) {
var temp;

0 comments on commit 5150873

Please sign in to comment.