Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

trying to minimalize the js code and want to increase the performance speed in js

const obj = {
  visible: {
    test1: false,
    test2: false,
    test3: false,
    test4: false,
    test5: false,
    test6: false,
    test7: false,
    test8: false,
  },
  required: {
    test1: false,
    test2: false,
    test3: false,
    test4: false,
    test5: false,
    test6: false,
    test7: false,
    test8: false,
  },
};
const fields = [
  { field: 'test1', required: true },
  { field: 'test2', required: true },
  { field: 'test3', required: true },
  { field: 'test4' },
  { field: 'test5' },
];

fields.forEach(({ field, required }) => {
  const key = field; // `${field}${number}`;

  obj.visible[key] = true;
 
PREVIOUS NEXT
Tagged: #minimalize #js #code #increase #performance #speed #js
ADD COMMENT
Topic
Name
6+1 =