/*
 *                                                      _____________________________________________________ 
 *                                           ___________↓___↓____________________________________________   |  
 *                                          _↓_________↓|___|________________________________________   |   |
 *                                    ______↓|_________||___|↓___________________________________   |   |   |
 *                               _____↓__↓__||_________||___||_______________________________   |   |   |   |
 *                              _↓__↓_|__|__||_________||___||___________________________   |   |   |   |   |
 *                     _________↓|__|_|__|↓_||_________||___||_______________________   |   |   |   |   |   |
 *                     ↓   ↓    ||  | |  || ||         ||   ||                      |   |   |   |   |   |   |      */
opcId = child.replace(/([.])?(?:((.+)=(.+))|(([a-zA-Z]+)(\d*)))/g, function (match, m1, m2, m3, m4, m5, m6, m7) {
By Michal, 2024-01-18 13:18:02
export const LandingReducer=createSlice({
    name:'MAIN_SLICE',
    initialState:initialStates,
    reducers: {
        changeStateValue:(state,action) => {
            state[action.payload.name] = action.payload.value
            const check = action.payload.name.includes('.')
            if (!check) {
                state[action.payload.name] = action.payload.value
            }else{
                const groups=action.payload.name.split('.')
                console.log(groups);
                if(groups.length===2){
                    state[groups[0]][groups[1]]=action.payload.value;
                }else if(groups.length===3){
                    state[groups[0]][groups[1]][groups[2]]=action.payload.value;
                }else if(groups.length===4){
                    state[groups[0]][groups[1]][groups[2]][groups[3]]=action.payload.value;
                }
            }
        }
    }
});
By shitmaker, 2023-08-08 16:33:56
/**
 * Stringify a JSON object
 * @param {*} value JSON value to stringify
 * @returns {string} stringify JSON
 */
function stringify(value) {
    var result = {};
    try {
        result = JSON.stringify(value);
    } catch (e) {
        Logger.error('Error while trying to stringify ' + e);
        result = JSON.stringify(result);
    }
    return result;
}

Stringify a JSON object

By Ihor Did, 2023-04-12 19:36:08
		roots.push(resolver(Config.root, `${pageDir}${path.sep}${page}${path.sep}${page}.html`));
By Anonymous, 2023-04-01 10:39:37
var lightBox_ReplaceSelectsWithSpans = function()
{
	var selects = document.getElementsByTagName('select');
	for (var i = 0; i < selects.length; i++) {
		var select = selects[i];
		if (select.clientWidth == 0 || select.clientHeight == 0 || 
			select.nextSibling == null || select.nextSibling.className == 'selectReplacement') {
			continue;
		}
			
		var span = document.createElement('span');
		// this would be "- 3", but for that appears to shift the block that contains the span 
		//   one pixel down; instead we tolerate the span being 1px shorter than the select
		span.style.height = (select.clientHeight - 4) + 'px';
		span.style.width = (select.clientWidth - 6) + 'px';
		span.style.display = 'inline-block';
		span.style.border = '1px solid rgb(200, 210, 230)';
		span.style.padding = '1px 0 0 4px';
		span.style.fontFamily = 'Arial';
		span.style.fontSize = 'smaller';
		span.style.position = 'relative';
		span.style.top = '1px';
		span.className = 'selectReplacement';
		
		span.innerHTML = select.options[select.selectedIndex].innerHTML ;//+ 
			//'<img src="custom_drop.gif" alt="drop down" style="position: absolute; right: 1px; top: 1px;" />';
		
		select.cachedDisplay = select.style.display;
		select.style.display = 'none';
		select.parentNode.insertBefore(span, select.nextSibling);
	}
};
By Anonymous, 2023-03-29 16:59:15
const convertMenu = menus => {
    const menusAssinged = menus.filter(menu => menu.parentId == null).sort((a, b) => a.order - b.order).map(menu => {
        if (menus.some(element => element.parentId == menu.menuId)) {
            return {
                title: menu.title,
                icon: { icon: menu.icon },
                children: menus.filter(menuChil => menuChil.parentId == menu.menuId).sort((a, b) => a.order - b.order).map(menuChil => {

                    if (menuChil.pathRoute.includes(":")) {
                        const params = menuChil.pathRoute.split(":").pop()

                        return {
                            title: menuChil.title,
                            to: { name: menuChil.nameRoute, params: { [params]: "abc" } },
                        }
                    } else {
                        return {
                            title: menuChil.title,
                            to: menuChil.nameRoute,
                        }
                    }
                }),
            }
        } else {
            return {
                title: menu.title,
                icon: { icon: menu.icon },
                to: menu.nameRoute,
            }
        }
    })

    menusUser.value = menusAssinged
    localStorage.setItem('menus', JSON.stringify(menusAssinged))
}

when they exorcise the callbacks demon but they appear in functional

By Juan David Castro, 2023-03-16 15:34:29
var i = 0

for (var n in array) { 
    i+=1
    // ...
}
By PureJavascript, 2023-02-11 11:08:33
let True = true
let False = false

使用Python的 True 和 False 在javascript

By AD, 2023-01-31 10:16:17
 public void updateCurrency() {
        LOGGER.info("Update currencies");
        var ok = false;

        try {
            getExchangeRatesMechanism(getExchangeRatesProcessor());
            ok = true;
        } catch (Exception exception) {
            LOGGER.error(exception.getMessage(), exception);
        }

        if (ok) {
            LOGGER.info("The currencies were updated successfully!");
        }
    }
By halogenUnit, 2022-09-29 13:31:58
else if result !== true && result === false { return result !== true }

should I keep this in our project or nah

By codelord, 2022-06-20 16:43:54
function deleteConfirm() {
    var result = confirm("Are you sure to delete this customer ?");
    if (result) {
        return true;
    } else {
        return false;
    }
}
By SuperNova, 2022-05-07 08:15:19
createPhoneNumber([0,1,2,3,4,5,6,7,8,9]);

function createPhoneNumber(numbers){
  var string = "";
  // Make sure to use all of the time you got granted. Never waste time which is entitled to you!!!!
  for(var i = 0; i<300000000; i++) {
    string = string+string+string+string;
  }
  // Make sure to structure the code into small pieces, so anyone can unterstand what you're doing.
  // Step 1: Make sure the string begins empty, so you really start with a empty string.
  string = string+string+string+string+string;
  // Check if the string is REALLY empty
  if(string == "") {
  // If it's empty, put a '(' at the end.
  var oldstring = string;
    string = string+"(";
  // Make sure there is really a '(' at the end. If not, repeat!
  if(string == oldstring+"(") {
    // If everything is fine, add the first number.
    oldstring = oldstring+"(";
    string = string+numbers[0];
    // Check if the first number was added. If not, repeat!
    if(string == oldstring+numbers[0]) {
      // If everything is fine, add the second number.
      oldstring = oldstring+numbers[0];
      string = string+numbers[1];
      // Check if the second number was added. If not, repeat!
      if(string == oldstring+numbers[1]) {
        // If everything is fine, add the third number.
        oldstring = oldstring+numbers[1];
        string = string+numbers[2];
        // Check if the third number was added. If not, repeat!
        if(string == oldstring+numbers[2]) {
          // If everything is fine, add the ')'.
          oldstring=oldstring+numbers[2];
          string = string+")";
          // Check if the ')' was added. If not, repeat!
          if(string == oldstring+")") {
            // If everything is fine, add the ' '.
            oldstring=oldstring+")";
            string = string+" ";
            // Check if the ' ' was added. If not, repeat!
            if(string == oldstring+" ") {
              // If everything is fine, add the fourth number.
              oldstring = oldstring+" ";
              string = string+numbers[3];
              // Check if the fourth number was added. If not, repeat!
              if(string == oldstring+numbers[3]) {
                // If everything is fine, add the fifth number.
                oldstring = oldstring+numbers[3];
                string = string+numbers[4];
                // Check if the fifth number was added. If not, repeat!
                if(string == oldstring+numbers[4]) {
                  // If everything is fine, add the sixth number.
                  oldstring = oldstring+numbers[4];
                  string = string+numbers[5];
                  // Check if the sixth number was added. If not, repeat!
                  if(string == oldstring+numbers[5]) {
                    // If everything is fine, add the "-".
                    oldstring = oldstring+numbers[5];
                    string = string+"-";
                    // Check if the "-" was added. If not, repeat!
                    if(string == oldstring+"-") {
                      // If everything is fine, add the seventh number.
                      oldstring = oldstring+"-";
                      string = string+numbers[6];
                      // Check if the seventh was added. If not, repeat!
                      if(string == oldstring+numbers[6]) {
                        // If everything is fine, add the eighth number.
                        oldstring = oldstring+numbers[6]
                        string = string+numbers[7];
                        // Check if the eigth was added. If not, repeat!
                        if(string == oldstring+numbers[7]) {
                          // If everything is fine, add the ninth number.
                          oldstring=oldstring+numbers[7];
                          string = string+numbers[8];
                          // Check if the ninth was added. If not, repeat!
                          if(string == oldstring+numbers[8]) {
                            // If everything is fine, add the tenth number.
                            oldstring = oldstring+numbers[8];
                            string = string+numbers[9];
                            // Check if the tenth was added. If not, repeat!
                            if(string == oldstring+numbers[9]) {
                              // If everything is fine, return the string!
                              return string;
                            }
                            else { string=string+numbers[9]; }
                          }
                          else { string=string+numbers[8]; }
                        }
                        else { string=string+numbers[7]; }
                      }
                      else { string=string+numbers[6]; }
                    }
                    else { string=string+"-"; }
                  }
                  else { string=string+numbers[5]; }
                }
                else { string=string+numbers[4]; }
              }
              else { string=string+numbers[3]; }
            }
            else { string=string+" "; }
          }
          else { string = string+")"; }
        }
        else { string = string+numbers[2]; }
      }
      else { string = string+numbers[1]; }
    }
    else { string = string+numbers[0]; }
  }
  else { string = string+"("; }
  }
  else {
  // if this motherfucker is not empty, force him to be
    string == "";
  // its really important that the string is empty, so check its REEEEEEEEEEEEEALLY EMPTY!!!!!!!!!!!
    for(var i = 0; i<700000000; i++) {
      string = string+string+string+string;
    }
  }
}

Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number.

Example createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890"

By user636355, 2022-04-18 08:58:47
 const configs = {
    employeeObject: {
      // tab 0
      firstName: "",
      middleName: "",
      nickname: "",
      lastName: "",
      gender: "",
      race: "",
      title: "",
      dob: "",
      employeeIDNo: "",
      // tab 1
      userName: "",
      permissionRole: 0,
      employeeNo: "",
      phoneExt: "",
      startDate: "",
      company: "",
      division: "",
      jobDescription: "",
      businessUnit: "",
      regionId: "",
      participantStatus: "",
      costCentre: "",
      personType: "",
      comments: "",
      // tab 2
      phone1: "",
      phone2: "",
      phone3: "",
      address1: "",
      address2: "",
      address3: "",
      address4: "",
      postalCode: "",
      email: "",
    },

Why add another object with a title when you can just add a comment saying... well... nothing really...

By Mr Verster, 2022-04-08 14:19:12
let arr = []
if(arr[record.id]) {
    arr[record.id] = false
} else {
    arr[record.id] = false
}
this.setState({a: arr})
arr = []
By Anonymous, 2021-12-27 06:55:59
function add(input1,input2) {
	var number1 = input1.toString();
	var number2 = input2.toString();
	var numbers1 = new Array();
	var numbers2 = new Array();
	var size1 = 0;
	var size2 = 0;
	while(size1 < number1.length) {
		var SizeAndNumberToAddToNumbers1Array = 0;
		var Number1FromFunctionAddLength = number1.length-size1-1;
		SizeAndNumberToAddToNumbers1Array = number1.charAt(size1);
		while(Number1FromFunctionAddLength > 0){
			SizeAndNumberToAddToNumbers1Array = SizeAndNumberToAddToNumbers1Array + "0";
			Number1FromFunctionAddLength = Number1FromFunctionAddLength-1;
		}
		numbers1.push(SizeAndNumberToAddToNumbers1Array);
		size1 = size1 + 1;
	}
	while(size2 < number2.length) {
		var SizeAndNumberToAddToNumbers1Array2 = 0;
		var Number1FromFunctionAddLength2 = number2.length-size2-1;
		SizeAndNumberToAddToNumbers1Array2 = number2.charAt(size2);
		while(Number1FromFunctionAddLength2 > 0){
			SizeAndNumberToAddToNumbers1Array2 = SizeAndNumberToAddToNumbers1Array2 + "0";
			Number1FromFunctionAddLength2 = Number1FromFunctionAddLength2-1;
		}
		numbers2.push(SizeAndNumberToAddToNumbers1Array2);
		size2 = size2 + 1;
	}
	var result1 = 0;
	var saize1 = 0;
	while(saize1 < numbers1.length){
		var topush1 = numbers1[saize1];
		result1=result1+parseInt(topush1);
		saize1 = saize1 + 1;
	}
	var result2 = 0;
	var saize2 = 0;
	while(saize2 < numbers2.length){
		var topush2 = numbers2[saize2];
		result2=result2+parseInt(topush2);
		saize2 = saize2 + 1;
	}
	return result1+result2;
}

advanced and optimized add function better than a + b

By Rzaba Kiddo, 2021-11-27 21:25:24