-2

I have an array that looks like this:

cardNumber: "2344234454562036"
cardType: "Visa"
cardholderName: "Yeyy"
cvv: "123"
expiryMonth: 12
expiryYear: 2022
postalCode: "52636"
redactedCardNumber: "••••••••••••2036"
__proto__: —'

I need to get the value of redactedCardNumber from that array.

The first thing that I am confused about is that when i print the above 'array' in the console, it actually show an object before everything! so is this an array or an object?

also, what is the best way of getting the specific item like 'redactedCardNumber' from it?

James Juanjie
  • 219
  • 3
  • 18
  • that is very clearly an object... arrays are indexed by number... this is a list of properties. How is this defined? – Leroy Stav Apr 09 '19 at 16:21
  • 1
    If it's an object, `theObject.redactedCardNumber`. If it's an array *containing* the object (for instance, at index `0`), `theArray[0].redactedCardNumber` (change the index as necessary). Details in the linked questions' answers. – T.J. Crowder Apr 09 '19 at 16:22
  • 1
    @T.J.Crowder, Thank you. I was confused and didn't know what it was! appologies for the useless question. – James Juanjie Apr 09 '19 at 16:24

1 Answers1

0

It looks like an object. If so, you can access it by obj.redactedCardNumber.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Ashok
  • 743
  • 4
  • 13