0

new to es6 here. is there any way to shorten this code with es6 features? i'm trying to destructure from an object and put those pulled properties into a new object.

    const { Height, Width, Location, MapAttachmentTypes, 
ZoomLevelAdjustment, CustomPushPins, CenterPushpinStyle, ScaleFactor } = args;
        const body = {
          Height,
          Width,
          Location,
          MapAttachmentTypes,
          ZoomLevelAdjustment,
          CustomPushPins,
          CenterPushpinStyle,
          ScaleFactor
        };

I tried this, but it didn't work:

const  body = { Height, Width, Location, MapAttachmentTypes, ZoomLevelAdjustment, CustomPushPins, CenterPushpinStyle, ScaleFactor } = args;
devdropper87
  • 3,215
  • 7
  • 30
  • 63

1 Answers1

-3
    // new syntax
    const body = {
        ...args
    };
    // es5
    const body = Object.assign({}, args);
Walle Cyril
  • 2,691
  • 2
  • 16
  • 46