I have a question about best practices and if it is possible or if it can/should be done this way to eliminate some "unnecessary" code. Can I create an if statement like this? I mean, at least it works for me, but is it normal?
var ModeloA = true,
ModeloB = false;
if (ModeloA) {
console.log("example");
}
if (!ModeloB) {
console.log("example");
}
Instead of:
if (ModeloA === true) {
console.log("example");
}
if (ModeloB !== true) {
console.log("example");
}
And in this case, can I do the same?
var ModeloC = document.querySelector("[class*=ModeloC]");
if (ModeloC) {
console.log("example");
}
Instead of:
var ModeloC = document.querySelector("[class*=ModeloC]");
if (ModeloC !== null) {
console.log("example");
}
Also, I just want to say that my javascript is not excellent, I learned it myself to automate some things that make my life easier (and I'm still learning). If anyone can help me, I'd be very grateful.