Skip to content

Instantly share code, notes, and snippets.

@rimiti
Created December 29, 2018 13:29
Show Gist options
  • Save rimiti/44a3d4030b099fd2812045b109188ba7 to your computer and use it in GitHub Desktop.
Save rimiti/44a3d4030b099fd2812045b109188ba7 to your computer and use it in GitHub Desktop.
Benchmark: Template string array stringified VS join() ?

Array stringified VS join(), who win ?

Template string (ES6)

function test() {
let array = ["email","groups_access_member_info","publish_to_groups","user_age_range","user_birthday","user_events","user_friends","user_gender","user_hometown","user_likes","user_link","user_location","user_photos","user_posts","user_tagged_places","user_videos"];

return `${array}`;
}

test();

Array.prototype.join();

function test() {
let array = ["email","groups_access_member_info","publish_to_groups","user_age_range","user_birthday","user_events","user_friends","user_gender","user_hometown","user_likes","user_link","user_location","user_photos","user_posts","user_tagged_places","user_videos"];

return array.join();
}

test();

Result available on JsPerf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment