Created
May 16, 2017 00:49
-
-
Save ConsciousUniverse/d141ed6627b9fc8688d701ff9efd4bd3 to your computer and use it in GitHub Desktop.
Javascript performance tests: Remove elements from array
This file contains hidden or 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
| let o1 = performance.now(); | |
| let test = ['a', 'b', 'c'] | |
| let toRemove = test.indexOf('b'); | |
| if(toRemove !== -1){ | |
| test.splice(toRemove, 1) | |
| console.log(test); | |
| } | |
| let o2 = performance.now(); | |
| console.log(o2 - o1); | |
| let t1 = performance.now(); | |
| let test2 = ['a', 'b', 'c']; | |
| console.log(test2.filter(v => v !== 'b')); | |
| let t2 = performance.now(); | |
| console.log(t2 - t1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment