-4

It's an array of object.I want to print only rgb value so that i can match it with other rgb value in if else statement. plz help.

 Color { _rgb: [ 4, 4, 4, 1, _clipped: false ] }
  • 2
    Welcome to Stack Overflow! Please visit the [help] to see what and [ask]. HINT: Post EFFORT and CODE. Please show input and expected output – mplungjan Mar 12 '18 at 06:33

1 Answers1

0

You can make your constructor function like,

function MyColor(color) {
    let rgb = color._rgb;
    [this.r, this.g, this.b] = [rgb[0], rgb[1], rgb[2]];
}
console.log(new MyColor(color));// MyColor { r: 40, g: 55, b: 67 }
vibhor1997a
  • 2,336
  • 2
  • 17
  • 37