Search
 
SCRIPT & CODE EXAMPLE
 

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;
Comment

PREVIOUS NEXT
Code Example
Javascript :: How to append variable with anchor element href link in Angularjs 
Javascript :: AngularJs: Display HTML elements from string variable in JSP page 
Javascript :: angularjs How to render either a number or a HTML element depending on what a function returns 
Javascript :: angularjs How to get time difference from ZoneDateTime in javascript 
Javascript :: How to set up path paramater in angular and access in the controller 
Javascript :: angularjs How to populate ng-style with object of CSS 
Javascript :: object Promise showing instead of data pulled from API call 
Javascript :: Se Chartjs horizontal 
Javascript :: I am getting an error "createSpyObj requires a non-empty array" with running unit tests, which were executed perfectly before 
Javascript :: How to spread state into a specific array 
Javascript :: Difficulties handling asynchronous taks using image-picker and copying files in react-native 
Javascript :: Save multiple radios checked on LocalStorage 
Javascript :: settimeout and create directory nodejs 
Javascript :: fields filtering in api from express 
Javascript :: p5 filter 
Javascript :: javascript check if key is keydown is charcter 
Javascript :: javascript datamatrix parser 
Javascript :: react state based router 
Javascript :: create a group or pool in phaser 
Javascript :: 120. Triangle - JavaScript Solution With Explantion 
Javascript :: chrome page transitions 
Javascript :: maptable elo 
Javascript :: communicate between content script and bg 
Javascript :: The JavaScript call() Method 
Javascript :: jQuery Misc Methods 
Javascript :: prisma get single data query 
Javascript :: var sumArray = function(arr) {}; 
Javascript :: Backbone With Express 
Javascript :: A Note on Jest & React 
Javascript :: remove parent element jquery 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =