Nut Fergie
Nut Fergie

Reputation: 89

How shorthand for assign more property object in js

Obj.a = xxx
Obj.b = yyy
Obj.c = zzz

I want to just typing to

With(obj){
a = xxx
b = yyy
c = zzz
}

With syntex is deprecate in es6

Upvotes: 0

Views: 42

Answers (2)

UlanTursunbek
UlanTursunbek

Reputation: 22

or you can use spread operator.

const obj = {...{}, a: "xxx", b: "yyy", c: "zzz"}

Upvotes: 0

Bergi
Bergi

Reputation: 664444

You can use Object.assign:

Object.assign(obj, {
  a: xxx,
  b: yyy,
  c: zzz,
})

Upvotes: 3

Related Questions