Skip to content

Instantly share code, notes, and snippets.

@rimiti

rimiti/README.md

Created Dec 29, 2018
Embed
What would you like to do?
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
You can’t perform that action at this time.