object - How do i point two fields to use the same value in javascript -
i have object below, , can see, "valid" , "pending" using same value, there way put in 1 line rather duplicating "custom-info" ?
map = { 'failed': 'custom-error', 'pending': 'custom-info', 'valid': 'custom-info' };
you can assign string value constant , set property value using constant.
const customer_info = 'custom-info'; map = { 'failed': 'custom-error', 'pending': customer_info, 'valid': customer_info };
this helps if setting property value many times , used somewhere else otherwise setting string value in object fine.
Comments
Post a Comment