Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Replicate Object
const replicateObject = (obj, times) => {
const tmp = JSON.stringify(obj);
return JSON.parse("[" + tmp.concat(",").repeat(times).slice(0, -1) + "]");
const example = {
n: 10,
prop1: "My Name",
prop2: "My Other Name"
const test = replicateObject(example, 100);
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.