current position:Home>js data manipulation problem solving?

js data manipulation problem solving?

2022-08-06 18:38:24segmentfault

Excuse me, I can only get the values ​​returned by the background, such as 1001 and the large area, on the interface 1. Now another interface 2 needs me to pass the parameter BUSDA when I am 1001. The following is their line.Correspondence, there are a total of 10 correspondences, I list three below, how to deal with the front end better, except for one if judgment

1001  Region BUSDA1002  Group BUSTU1003  Shop BUSPU


Other Answer 1:

Use the filter function and three paragraphs to judge


Other Answers 2:

Use the object object to store the mapping relationship:

const id2code = {1001: 'BUSDA',1002: 'BUSTU',1003: 'BUSPU',}

copyright notice
author[segmentfault],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/218/202208021526430177.html

Random recommended