Duplicating an data object
See original GitHub issueHello, in order to duplicate an object with all its children, I had to use a jQuery function, please is there a better way in Vue? I am using Vue 0.12.1
duplicateThis: function (field) {
var currentField = this.fields[field.index];
var insertField = {
name: currentField.name,
type: currentField.type,
description: currentField.description,
options: $.extend(true, {}, currentField.options),
required: currentField.required
};
this.fields.splice(field.index + 1, 0, insertField);
}
Thank you
Issue Analytics
- State:
- Created 8 years ago
- Comments:19 (1 by maintainers)
Top Results From Across the Web
3 Ways to Clone Objects in JavaScript | SamanthaMing.com
# 1. Using Spread ... Using spread will clone your object. Note this will be a shallow copy. As of this post, the...
Read more >Object copying - Wikipedia
In object-oriented programming, object copying is creating a copy of an existing object, a unit of data in object-oriented programming. The resulting object...
Read more >Duplicating Objects - Foundry Learn
You can duplicate child objects but not parent objects, locators, or child locators. Duplicating an object creates a copy of it and adds...
Read more >How to copy objects in JavaScript: A complete guide
A complete guide to copying objects in JavaScript: shallow copy, deep copy, assigning, merging, and structured cloning.
Read more >Create Duplicate Object (CRTDUPOBJ) - IBM
The Create Duplicate Object (CRTDUPOBJ) command copies a single object or a group of objects. It does not create an exact duplicate of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Have you tried
JSON.parse(JSON.stringify(field))
?var obj = { a: 1 }; var copy = Object.assign({}, obj); console.log(copy); // { a: 1 }