$.extend deep copy vs JSON serialize/deserialize

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Extend
var original = {
  "foo": "bar",
  "myArray": ["apples", "bananas", "oranges"],
  "motor": "cycle",
  "indigo": "scheduling",
  "something": "or another"
};
var newCopy = $.extend(true, {}, original);
pending…
JSON serialize
var original = {
  "foo": "bar",
  "myArray": ["apples", "bananas", "oranges"],
  "motor": "cycle",
  "indigo": "scheduling",
  "something": "or another"
};
var newCopy = JSON.parse(JSON.stringify(original))
pending…
Extend without array
var original = {
  "foo": "bar",
  "motor": "cycle",
  "indigo": "scheduling",
  "something": "or another"
};
var newCopy = $.extend(true, {}, original);
pending…
JSON without array
var original = {
  "foo": "bar",
  "motor": "cycle",
  "indigo": "scheduling",
  "something": "or another"
};
var newCopy = JSON.parse(JSON.stringify(original))
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment