Created
August 15, 2008 22:00
-
-
Save gpbmike/5663 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [1,3,2,4]; | |
console.log(arr); | |
var sorted_arr = arr.sort(); | |
console.log(sorted_arr); | |
console.log(arr); | |
// prints what i don't want | |
// [1,3,2,4] | |
// [1,2,3,4] | |
// [1,2,3,4] | |
var arr = [1,3,2,4]; | |
console.log(arr); | |
var sorted_arr = arr.slice().sort(); | |
console.log(sorted_arr); | |
console.log(arr); | |
// prints what i want! | |
// [1,3,2,4] | |
// [1,2,3,4] | |
// [1,3,2,4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment