5190 const lw = columns == 1 ? 0 : nuPortraitLabelWidth(obj)
5191 let top = 0
5192 let b = -1
5193 var width = 05194 let oWidth = 0
5195 let oTop = 0
5196
4578 .html('<span style="font-weight:bold"> ' + nuTranslate('Include When Searching') + '<\span>')
4579 .addClass('nuOptionsList')
4580
4581 for (var i = 0; i < c.length; i++) {4582 let isChecked = true
4583
4584 if ($.inArray(i, nuFORM.getCurrent().nosearch_columns) != '-1') {
4336
4337 if (c === null) return
4338
4339 for (var i = 0; i < c.length; i++) {4340 if (c[i].subform) {
4341 $('#' + c[i].id + 'scrollDiv' + ' > .nuSubform1').remove()
4342 $('#' + c[i].id + 'scrollDiv' + ' > .nuSubform0').each(function () {
It is recommended to use let
or const
over var
.
This will help prevent re-declaration of variables that are in the global scope when using var
.
ES6 allows programmers to create variables with block scope instead of function scope using the let
and const
keywords.
Block scope is common in many other programming languages and helps programmers avoid mistakes such as this one:
var count = people.length;
var enoughFood = count > sandwiches.length;
if (enoughFood) {
var count = sandwiches.length; // accidentally overriding the count variable
console.log("We have " + count + " sandwiches for everyone. Plenty for all!");
}
// our count variable is no longer accurate
console.log("We have " + count + " people and " + sandwiches.length + " sandwiches!");
Block scoped variables shadow outer declarations instead of writing to them.
NOTE: There are certain edge cases where users might want to consider var. Consider this example:
var lib = lib || { run: () => {} }
Here, lib
might be a library that is exposed to an HTML file using a <script>
tag.
The var
keyword helps avoid re-writing lib
if it has already been declared via an injected script that was executed before this one.
Ideally, you should let bundlers worry about cases like this.
But if you want to use var
anyway, consider using a skipcq comment, or disabling the issue altogether.
Bad Practice
var x = "y";
var CONFIG = {};
Recommended
let x = "y";
const CONFIG = {};