styleArr = data.items[0].companys_self_type_styleid.split(',')matArr = data.items[0].companys_self_type_matid.split(',')fieldArr = data.items[0 ].companys_self_type_fieldid.split(',')
Is there a simple way to write it
[styleArr, matArr, fieldArr] = [styleArr, matArr, fieldArr].map((key, index) => data.items[0]["companys_self_type" + [ "styleid", "matid", "fieldid" ][index]].split(','))
function deal(n){ return data.items[0].n.split(',') } styleArr = deal(companys_self_type_styleid); matArr = deal(companys_self_type_matid); fieldArr = deal(companys_self_type_fieldid);
var data = {}; for (var prop in data.items[0]) { var i = prop.substring(prop.lastIndexOf('_') + 1, prop.lastIndexOf('id')) + 'Arr'; data[i] = data.items[0][prop].split(','); }
var arr = data.items[0].companys_self_type_styleid.split(',');var styleArr,matArr,fieldArr styleArr = matArr = fieldArr = arr ;
var arr = data.items[0].companys_self_type_styleid.split(',');
var styleArr,matArr,fieldArr
styleArr = matArr = fieldArr = arr ;