Skip to content

Instantly share code, notes, and snippets.

@harithzainudin
Created July 31, 2022 16:11
Show Gist options
  • Save harithzainudin/ff97381208ee383adf4504ea0f9dff52 to your computer and use it in GitHub Desktop.
Save harithzainudin/ff97381208ee383adf4504ea0f9dff52 to your computer and use it in GitHub Desktop.
Difference between Lodash concat & Javascript native concat
const _ = require("lodash");
const myClassmates = ["John", "Jane"];
const mySenior = ["Alice", "Bob"];
console.time("Native concat");
const students2 = myClassmates.concat(mySenior);
console.timeEnd("Native concat");
console.time("Lodash concat");
const students = _.concat(myClassmates, mySenior);
console.timeEnd("Lodash concat");
// Both result will be - [ 'John', 'Jane', 'Alice', 'Bob' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment