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
  • 4,025
  • 11
  • 44
  • 70

1 Answers1

-3
    // new syntax
    const body = {
        ...args
    };
    // es5
    const body = Object.assign({}, args);
Walle Cyril
  • 3,087
  • 4
  • 23
  • 55