jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
var arr = [{id: 1234, filterName: "Filter by Author", value: "author"}, {id: 1234, filterName: "Filter by Author", value: "author"}, {id: 5678, filterName: "Filter by Book Type", value: "bookType"}];
function unshift() {
arr.unshift({
id: '0000', filterName: "Choose a Filter", value: ""
});
return arr;
}
function concat() {
return [{id: '0000', filterName: "Choose a Filter", value: ""}
].concat(arr)
}
function spread() {
return [{id: '0000', filterName: "Choose a Filter", value: ""
}, ...arr]
}
function splice() {
return arr.splice(0,0, {id: '0000', filterName: "Choose a Filter", value: ""
})
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Add a new option to Array of filters at position 0 with unshift |
| ready |
Add a new option to Array of filters at position 0 with concat |
| ready |
Add a new option to Array of filters at position 0 with spread operator |
| ready |
Add a new option to Array of filters at position 0 with splice |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.