Optimize ternary operator

That’s just horrible code. It’s badly formatted. I don’t see the hierarchy of the expression. Even if it had good formatting, the expression would be way too complex to quickly parse with the human eye. The intention is unclear. What’s the purpose of those conditions? So what can you do? Use conditional statements (if). Extract … Read more

Count the number of true members in an array of boolean values

Seems like your problem is solved already, but there are plenty of easier methods to do it. Excellent one: .filter(Boolean); // will keep every truthy value in an array const arr = [true, false, true, false, true]; const count = arr.filter(Boolean).length; console.log(count); Good one: const arr = [true, false, true, false, true]; const count = … Read more

Ternary operator in JSTL/EL

I tested the following page in Tomcat 5.59, JSP 2.0 and JSTL 1.1. It ran without any errors. <%@taglib uri=”http://java.sun.com/jsp/jstl/core” prefix=”c”%> <c:set var=”value” scope=”request” value=”someValue”/> <c:out default=”None” escapeXml=”true” value=”${not empty value ? value : ‘None’}” /> <c:out default=”None” escapeXml=”true” value=”${empty value ? ‘None’ : value}” /> <c:set var=”value” scope=”request” value=”” /> <br/> <c:out default=”None” escapeXml=”true” … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)