let showDots = typeof project.showDots === 'boolean' ? project.showDots : false;

if (showDots) {
    // Somecode ...
}

Why, just why??

By Anonymous, 2017-08-08 11:41:49
if (botCount < botCount)
    this.reconnect();
}

My friend wrote this code recently

By Anonymous, 2017-12-13 17:47:25
$options.splice($options.indexOf('option7'), 1);
$options.splice($options.indexOf('option5'), 1);
$options.splice($options.indexOf('option4'), 1);
$options.splice($options.indexOf('option3'), 1);
$options.splice($options.indexOf('option2'), 1);
$options.splice($options.indexOf('option1'), 1);
By A "senior" developer, 2018-02-19 16:49:52
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
//Calculates x² of an integer up to ±1 million
var square = (function () {
	var s = "if(A==B){return C;}";
	var func = "var A=Math.abs(D|0);";
	for (var i = 0; i <= 1000000; i++) {
		func += s.replace(/B/, i).replace(/C/, i * i);
	}
	return new Function("D", func + "return Infinity;");
})();
By Anonymous, 2017-12-13 16:53:27
function IsNumeric(sText) {
    var ValidChars = "0123456789.";
    var IsNumber = true;
    var Char;
    for (i = 0; i < sText.length && IsNumber == true; i++) {
        Char = sText.charAt(i);
        if (ValidChars.indexOf(Char) == -1) {
            IsNumber = false;
        }
    }
    return IsNumber;
}

So I suppose that "........" is a valid number...

By L, 2019-07-10 16:05:03
function uberURLREPLACER(dtTEXTVALUE,boolVALUE){
    
// If statement? what's that?? 
// Naming conventions? Of course not! 
// true/false keywords? I never heard it.
boolVALUE != !1 && dtTEXTVALUE.indexOf('http://') != -1 && (dtTEXTVALUE = dtTEXTVALUE.replace('http://','')) && dtTEXTVALUE.indexOf('.aspx') == -1 && (dtTEXTVALUE += '.aspx');

return dtTEXTVALUE;

}

Here's the weirdest way to create if statement with terrible naming conventions. Its based on real events and production code.

By I've no idea, 2019-02-16 13:16:07
(this.router.state['view']['data'] || {})['menuOpen'] && this.router.navigateBack();

That's how pros are javascripting

By Igor, 2017-07-06 04:00:05
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
request.get_something = (something_id) => {
  return new Promise((resolve, reject) => {
    database.find_all('something', { where: {something_id: something_id, is_deleted:0} }).then(function(res){
      let result = {};
      res = JSON.stringify(res);
      res = JSON.parse(res);
      res.forEach(function(element){
        if(typeof element.is_deleted != "undefined"){
          delete element.is_deleted;
        }
        let key = 'something_' + element.id;
        result[key] = element;
      });
      resolve(result);
    }, reject);
  });
}

I LOVE MY JOB!

By ADyingDeveloper, 2018-04-05 17:24:33
return isDisabled == false ? false : true;
By Anonymous, 2018-03-23 22:02:31
// var array = retrieveArrayValue();
var filteredArray = array.filter(function (element, index, array) {
    return array.indexOf(element) == index;
});
// processArray(filteredArray);
By Anonymous, 2020-08-20 11:24:51
set_locations(locations){
    return new Promise((resolve, reject) => {
        this.locations = locations;
        resolve();
    });
}
By Anonymous, 2018-04-04 14:44:45
function clean(toClean, source){
	if (typeof(toClean) !== 'string') return true;
	if (typeof(source) !== 'string') return true;
	
	return source.replace(toClean, String('CLEANED')).toString();
}

Found this in a project at work and someone clearly doesn't trust JavaScripts typeof function

By Anonymous, 2018-06-02 22:09:57
Handlebars.registerHelper("compare", function(a, operator, b) {
    var result = false;

    try {
      switch (operator) {
        case "==":
          // eslint-disable-next-line eqeqeq
          result = a == b;
          break;
  
        case "===":
          result = a === b;
          break;
  
        case "!=":
          // eslint-disable-next-line eqeqeq
          result = a != b;
          break;
  
        case "!==":
          result = a !== b;
          break;
  
        case "<":
          result = a < b;
          break;
  
        case ">":
          result = a > b;
          break;
  
        case "<=":
          result = a <= b;
          break;
  
        case ">=":
          result = a >= b;
          break;
  
        case "typeof":
          // eslint-disable-next-line valid-typeof
          result = typeof a === b;
          break;
  
        default: {
          throw new Error(
            "helper {{compare}}: invalid operator: ' + ".concat(operator, " + '")
          );
        }
      }
    } catch (err) {
      console.error("\n********** ".concat(err, "."));
    }
  
    return result;
});
By Anonymous, 2019-04-02 15:46:35