var u = "Browser";
        if (this.isIPad) {
            u = "iPad"
        } else {
            if (this.isDDGIgnore) {
                u = "Ignore"
            } else {
                if (/seamonkey/.test(x)) {
                    u = "SeaMonkey"
                } else {
                    if (/iceape/.test(x)) {
                        u = "Iceape"
                    } else {
                        if (/palemoon/.test(x)) {
                            u = "PaleMoon"
                        } else {
                            if (this.isFirefox) {
                                u = "Firefox"
                            } else {
                                if (this.isAndroid) {
                                    u = "Android"
                                } else {
                                    if (/xbox/.test(x)) {
                                        u = "xBox"
                                    } else {
                                        if (/midori/.test(x)) {
                                            u = "Midori"
                                        } else {
                                            if (/opr/.test(x)) {
                                                u = "Opera"
                                            } else {
                                                if (/maxthon/.test(x)) {
                                                    u = "Maxthon"
                                                } else {
                                                    if (this.isYandex) {
                                                        u = "Yandex"
                                                    } else {
                                                        if (/vivaldi/.test(x)) {
                                                            u = "Vivaldi"
                                                        } else {
                                                            if (this.isChrome) {
                                                                u = "Chrome"
                                                            } else {
                                                                if (/fennec/.test(x)) {
                                                                    u = "Fennec"
                                                                } else {
                                                                    if (/epiphany/.test(x)) {
                                                                        u = "Epiphany"
                                                                    } else {
                                                                        if (this.isFirefox) {
                                                                            u = "Firefox"
                                                                        } else {
                                                                            if (/uzbl/.test(x)) {
                                                                                u = "Uzbl"
                                                                            } else {
                                                                                if (this.isEdge) {
                                                                                    u = "Edge"
                                                                                } else {
                                                                                    if (this.isIE && navigator.platform === "Win64" && !k() && Modernizr.touch && document.documentElement.clientWidth == screen.width) {
                                                                                        u = "IEMetro"
                                                                                    } else {
                                                                                        if (this.isIE) {
                                                                                            u = "IE"
                                                                                        } else {
                                                                                            if (this.isOpera) {
                                                                                                u = "Opera"
                                                                                            } else {
                                                                                                if (this.isIPhone) {
                                                                                                    u = "iPhone"
                                                                                                } else {
                                                                                                    if (/arora/.test(x)) {
                                                                                                        u = "Arora"
                                                                                                    } else {
                                                                                                        if (this.isSafari) {
                                                                                                            u = "Safari"
                                                                                                        } else {
                                                                                                            if (this.isKonqueror) {
                                                                                                                u = "Konqueror"
                                                                                                            } else {
                                                                                                                if (this.isBlackberry) {
                                                                                                                    u = "Blackberry"
                                                                                                                } else {
                                                                                                                    if (/phantomjs/.test(x)) {
                                                                                                                        u = "PhantomJS"
                                                                                                                    } else {
                                                                                                                        if (this.isIDevice) {
                                                                                                                            u = "iOS"
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

Found when looking at facebook.com code and formatting using google chrome developer tools.

By jcubic, 2017-01-03 18:38:30
var show = true;

function toggleShow(){
    if(show === true){
        show = false;
        return show;
    }else{
        show = true;
        return show;
    }
}

return show = !show, dude...

By Anonymous, 2017-07-14 09:50:57
if(wyraz.charAt(i) <"A" 
        && wyraz.charAt(i) != "-" 
            && wyraz.charAt(i)  != " " 
                && wyraz.charAt(i) != "." 
                    && wyraz.charAt(i) != "&" 
                        && wyraz.charAt(i) != "_" 
                            && wyraz.charAt(i) != "\"" 
                                && wyraz.charAt(i) != "'" 
                
) {                
    if(polska_litera(wyraz.charAt(i) ) == 0 ) 
                return NO; 
}
if(wyraz.charAt(i) >"Z" 
           && wyraz.charAt(i) != "-" 
                && wyraz.charAt(i)  != " " 
                    && wyraz.charAt(i) != "." 
                        && wyraz.charAt(i) != "&" 
                            && wyraz.charAt(i) != "_" 
                                && wyraz.charAt(i) != "\""
                                    && wyraz.charAt(i) != "'"
)

Just PKP :)

By Slacki, 2015-07-20 22:43:47
function focused(evt, errors) {
	let form = evt.target

	const output = errors.map((error)=> {

		// Find first component with error on form and set focus to it

		let focusedInput = (Object.keys(error) == "phonebookId") ? Object.keys(error) :
			(Object.keys(error) == "phonebook_str") ? Object.keys(error) :
				(Object.keys(error) == "message") ? Object.keys(error) :
					(Object.keys(error) == "image") ? Object.keys(error) :
						(Object.keys(error) == "buttonLink") ? Object.keys(error) :
							(Object.keys(error) == "messageSms") ? Object.keys(error) : false
		return focusedInput.shift()
	})

	const selector = output.shift()
	form.querySelector('[id="' + selector + '"]').focus()

	return selector
}

What can I say... If you plan to work with freelancers with low rate then you should be ready to find it in them code :)

By Ya, 2016-10-02 12:16:46
$scope.$$childHead.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling.$$nextSibling

Was trying to find a very specific text box and as an AngularJS noob, this was the only way I could find it at first. I eventually figured out how to not do this before it ever got committed to production though. :)

By Anonymous, 2017-12-12 16:47:10
var filter = options.dataSource.filter();

if(e.filter) {
   filter = filter && filter.filters.length ? filter.filters.concat(e.filter.filter) : e.filter.filters;
}
else {
   filter = filter && filter.filters.length ? filter.filters.linqRemove({ field: e.field }) : [];
}
options.dataSource.filter(filter);
By Anonymous, 2018-02-09 19:03:07
function returnTrue() {
    return true;
}
By Anonymous, 2019-12-19 19:41:56
// Is this valid?
function validateStockInItems() {
    if (stockInItemsToUpdate.length === 0)
        return true;
    return true;
}

Found in a legacy code base for a stock management system. I will be rewriting said system soon.

By Anonymous, 2017-12-13 09:15:42
o.isInsured = function ()
{ return !!this.insured; }

Why don't be like normal people and use bool() cast?

By Anonymous, 2018-09-22 14:31:37
function formatUpToANumberOfZeroesAfterFloatingPoint(number, numberOfZeroes, floatingPointSymbol) {
    numberOfZeroes = (numberOfZeroes === undefined || numberOfZeroes < 0) ? 2 : numberOfZeroes;
    floatingPointSymbol = floatingPointSymbol === undefined ? '.' : floatingPointSymbol;
    let numberSplitByFloatingPoint = number.toString().split(floatingPointSymbol);
    if (numberSplitByFloatingPoint.length !== 2) 
        return `${number}${floatingPointSymbol}${'0'.repeat(+numberOfZeroes)}`;
    
    let numberAfterFloatingPoint = numberSplitByFloatingPoint[1].toString();
    let formattedNumber = `${numberSplitByFloatingPoint[0]}`;
    let numberAfterFloatingPointLength = numberAfterFloatingPoint.toString().length;
    if (+numberOfZeroes > +numberAfterFloatingPointLength) 
        return `${formattedNumber}${floatingPointSymbol}${numberAfterFloatingPoint}${'0'.repeat(+numberOfZeroes - numberAfterFloatingPointLength)}`;
    
    let countOfNumbersAfterFloatingPoint = numberAfterFloatingPointLength;
    for (var i = numberAfterFloatingPointLength - 1; i >= 0; i--) {
        if (+(numberAfterFloatingPoint[i]) !== 0 || +countOfNumbersAfterFloatingPoint === +numberOfZeroes) {
            formattedNumber += `${floatingPointSymbol}${numberAfterFloatingPoint.substring(0, countOfNumbersAfterFloatingPoint)}`;
            break;
        }
        
        countOfNumbersAfterFloatingPoint--;
    }

    return formattedNumber;
}

Well, a junior dev here. A cute female QA came to me with a request - "the field for the price already has precision up to 4 decimal places, but we don't like the 4 ugly zeroes, so if the number ends in zeroes, let it have only 2" - she said in the most innocent-like tone ever known to mankind. How easy I mumbled and accepted the task. As she was leaving she added - "oo almost forgot, we also would like it if all the data fields for the price that are shown in the tables also are formatted that way". As I was watching her better side, while she was getting reunited with her QA tribe, I got shivers down the spine. I had a bad feeling about that one, but I wasn't sure why yet. Suddenly as I was getting up to get a cup of coffe, it dawned on me - "this poor excuse for a project is using jqGrid for displaying the data". To wrap things up - I got a quadruple espresso with a shot of Jacky, developers best friend in a time of need, and came up with this piece of art. Enjoy :)

By Kristopher Alexander, 2019-04-25 15:49:53
var query = $("#search-query");
query.click(function() {
  if (query.val() == 'szukaj...') {
     query.val('');
  }
});
By Kadet, 2016-02-14 14:54:32
for(var j=0;j<10;j++){
    cell=document.createElement('td');
    switch(j)
    {
        case 0: 
            var date1 = events[i]['start'];
            var date2 = events[i]['end'];
            cell.appendChild(document.createTextNode(date1.getFullYear()+'/'+date1.getMonth()+'/'+date1.getDate()+' '+date1.getHours()+':'+date1.getMinutes()+' To '+date2.getFullYear()+'/'+date2.getMonth()+'/'+date2.getDate()+' '+date2.getHours()+':'+date2.getMinutes())); 
            break;
        case 1: cell.appendChild(document.createTextNode(events[i]['title'])); break;
        case 2: cell.appendChild(document.createTextNode(events[i]['description'])); break;
    }
    row.appendChild(cell);
}

The for loop that counts to 10, but the last seven elements are completely useless.

By Anonymous, 2017-12-13 07:16:36
const errorHandler = () => {
  throw new Error();
};
By Anonymous, 2018-10-08 19:35:38
let foo = {} // object no. 1
let bar = {} // object no. 2

foo > bar // return false
foo < bar // return false, so maybe foo equals bar?
foo == bar // oh well, return false
// but
foo >= bar // return true, 'cause !(foo < bar) == true

return value is expected, but JS is funny

By Anonymous, 2021-03-12 21:08:32
if(
  (!_.isEmpty($(switcher).val()) && value_isnt == ":empty") ||
  ((value_isnt) && !$(switcher).is(value_isnt) && value_isnt != ':empty') ||
  (value_is && $(switcher).is(value_is) && value_is != ':empty') ||
  (value_is == ':empty' && _.isEmpty($(switcher).val())) ||
  (value && _switcherValue == value) ||
  (valueIn && .anyMatchInArray(valueIn.split(','), .flatten([_switcherValue]))) ||
  (valueOut && !.anyMatchInArray(valueOut.split(','), .flatten([_switcherValue])))
)
By Alex, 2017-06-08 15:58:10