All Questions
9
questions
1
vote
3
answers
3k
views
difference between ...this.state and this.state
In my react application I am passing parent's state to child as a prop like so:
<Child parentsState={...this.state} />
and it works. but then i thought why not should i pass this.state without ...
0
votes
1
answer
16k
views
How to use spread operator to add property to an object, not override it?
I have this function.
function foo(newdata) {
utils.method('GET', '/auth', {
response: {
data: {
settings: {
last_email_notification_shown_date: new ...
0
votes
5
answers
239
views
Object.assign() , merge/overwrite keys, to copy the values of an array to create an object
i used to have an array with one object, like so:
var myObj = [{'key': {an object}}];
I convert it to an object like so:
Object.assign({}, ...myobj)
to get this : {'key': [{an object}]}
The ...
1
vote
1
answer
723
views
merge props from nested objects as one single object using es6
Suppose we are given the following:
const Patients = {
P1: {
"name": "Person1",
"profession": "Student",
"gender": "Male",
"type": "Patient",
"Doctors": {...}
},
...
5
votes
3
answers
8k
views
Adding multiple objects using object spread operator (ES6, JavaScript)
i have 3 objects having same data but inside array having separate service and offer id so i tried to get expected result as below mentioned and please check my try here . Thanks in advance
Object 1:...
0
votes
1
answer
50
views
How to simplify with spread syntax es6
How to simplify the code, I tried to generate the object and call for each change method and depends on arguments(newValues) I change some field, seems I have duplicate code, how to avoid it this case?...
19
votes
4
answers
27k
views
spread operator converting objects to array
I'm trying to convert a data structure like this:
data = {
0:{A:a},
1:{B:b},
2:{C:c},
}
into a structure like this:
[
{0:{A:a}},
{1:{B:b}},
{2:{C:c}},
]
Using the spread operator ...
18
votes
3
answers
7k
views
how to use object spread syntax in chrome dev tools
I started using object spread syntax to safely make a copy of the object while following immutability principles.
I want to use it in chrome developer console - how to do this:
0
votes
4
answers
80
views
How to add a method with ES6 Rest to a JS object [duplicate]
I have a Person constructor and I want to add a method supposed to add friends. I want to allow my user to pass a variable number of friends so I thought about the new "rest" feature of ES6. Sadly, I ...