Reputation: 10571
I use
let op = data.map(({usp-custom-90})=> usp-custom-90 )
but that gives
Uncaught SyntaxError: Unexpected token -
I tried to replace dash with – but then I get errors in regards of &
How do I fix it?
Upvotes: 1
Views: 662
Reputation: 141829
Identifiers cannot contain hyphens, so you must rename the property to a valid identifier name:
let op = data.map( ({ ['usp-custom-90']: uspCustom90 }) => uspCustom90 )
Upvotes: 3
Reputation: 1
You can use computed property name
let prop = `usp-custom-90`
let op = data.map(({[prop]:p})=> p)
Upvotes: 3