'i' used outside of binding context.
100 t = o[$('#sfo_type').val()]
101 if (t !== undefined) {
102 for (i = 0; i < t.length; i++) {
103 $('#nuTab' + t[i]).addClass('nuRelatedTab')104 }
105 }
106}
'i' used outside of binding context.
99
100 t = o[$('#sfo_type').val()]
101 if (t !== undefined) {
102 for (i = 0; i < t.length; i++) {103 $('#nuTab' + t[i]).addClass('nuRelatedTab')
104 }
105 }
'i' used outside of binding context.
99
100 t = o[$('#sfo_type').val()]
101 if (t !== undefined) {
102 for (i = 0; i < t.length; i++) {103 $('#nuTab' + t[i]).addClass('nuRelatedTab')
104 }
105 }
'i' used outside of binding context.
99
100 t = o[$('#sfo_type').val()]
101 if (t !== undefined) {
102 for (i = 0; i < t.length; i++) {103 $('#nuTab' + t[i]).addClass('nuRelatedTab')
104 }
105 }
'i' used outside of binding context.
248
249 t = o[$('#sfo_type').val()]
250 if (t !== undefined) {
251 for (i = 0; i < t.length; i++) {252 $('#nuTab' + t[i]).addClass('nuRelatedTab')
253 }
254 }
'i' used outside of binding context.
248
249 t = o[$('#sfo_type').val()]
250 if (t !== undefined) {
251 for (i = 0; i < t.length; i++) {252 $('#nuTab' + t[i]).addClass('nuRelatedTab')
253 }
254 }
'i' used outside of binding context.
248
249 t = o[$('#sfo_type').val()]
250 if (t !== undefined) {
251 for (i = 0; i < t.length; i++) {252 $('#nuTab' + t[i]).addClass('nuRelatedTab')
253 }
254 }
'i' used outside of binding context.
249 t = o[$('#sfo_type').val()]
250 if (t !== undefined) {
251 for (i = 0; i < t.length; i++) {
252 $('#nuTab' + t[i]).addClass('nuRelatedTab')253 }
254 }
255
'_nuSelectBrowse' used outside of binding context.
354 if (nuMainForm()) {
355 nuSelectBrowseMainForm(e, t)
356 } else {
357 _nuSelectBrowse(e, t)358 }
359}
360
'subform_name' used outside of binding context.
477
478 for (let i = 0; i < d.length; i++) {
479 const SF = d[i]
480 if (SF.id == subform_name) { // -- i've got the right subform481 // var fmt = $("[id$='" + field_name + "']input[id^='" + subform_name + "']").attr('data-nu-format')
482 var f = SF.fields.indexOf(field_name) // -- check for valid field(column)
483 if (f == -1) { return 0 }
'field_name' used outside of binding context.
479 const SF = d[i]
480 if (SF.id == subform_name) { // -- i've got the right subform
481 // var fmt = $("[id$='" + field_name + "']input[id^='" + subform_name + "']").attr('data-nu-format')
482 var f = SF.fields.indexOf(field_name) // -- check for valid field(column)483 if (f == -1) { return 0 }
484 for (let c = 0; c < SF.rows.length; c++) {
485 if (SF.deleted[c] == 0) { // -- add up only stuff not being deleted
'f' used outside of binding context.
479 const SF = d[i]
480 if (SF.id == subform_name) { // -- i've got the right subform
481 // var fmt = $("[id$='" + field_name + "']input[id^='" + subform_name + "']").attr('data-nu-format')
482 var f = SF.fields.indexOf(field_name) // -- check for valid field(column)483 if (f == -1) { return 0 }
484 for (let c = 0; c < SF.rows.length; c++) {
485 if (SF.deleted[c] == 0) { // -- add up only stuff not being deleted
'f' used outside of binding context.
480 if (SF.id == subform_name) { // -- i've got the right subform
481 // var fmt = $("[id$='" + field_name + "']input[id^='" + subform_name + "']").attr('data-nu-format')
482 var f = SF.fields.indexOf(field_name) // -- check for valid field(column)
483 if (f == -1) { return 0 }484 for (let c = 0; c < SF.rows.length; c++) {
485 if (SF.deleted[c] == 0) { // -- add up only stuff not being deleted
486 u = SF.rows[c][f]
'f' used outside of binding context.
483 if (f == -1) { return 0 }
484 for (let c = 0; c < SF.rows.length; c++) {
485 if (SF.deleted[c] == 0) { // -- add up only stuff not being deleted
486 u = SF.rows[c][f]487 v = parseFloat(Number(v) + Number(u)).toPrecision(10)
488 }
489 }
'v' used outside of binding context.
472 }
473
474 const d = this.data() // -- an array of all data as subforms (the mainform is the first element)
475 var v = 0476 let u = 0
477
478 for (let i = 0; i < d.length; i++) {
'v' used outside of binding context.
484 for (let c = 0; c < SF.rows.length; c++) {
485 if (SF.deleted[c] == 0) { // -- add up only stuff not being deleted
486 u = SF.rows[c][f]
487 v = parseFloat(Number(v) + Number(u)).toPrecision(10)488 }
489 }
490
'v' used outside of binding context.
484 for (let c = 0; c < SF.rows.length; c++) {
485 if (SF.deleted[c] == 0) { // -- add up only stuff not being deleted
486 u = SF.rows[c][f]
487 v = parseFloat(Number(v) + Number(u)).toPrecision(10)488 }
489 }
490
'v' used outside of binding context.
488 }
489 }
490
491 return Number(v)492 }
493 }
494
'f' used outside of binding context.
465 var field_name = field.split('.')[1]
466 } else {
467 const o = $('#' + field)
468 var f = o.attr('data-nu-format')469 var v = o.val()
470
471 return nuFORM.removeFormatting(v, f)
'f' used outside of binding context.
468 var f = o.attr('data-nu-format')
469 var v = o.val()
470
471 return nuFORM.removeFormatting(v, f)472 }
473
474 const d = this.data() // -- an array of all data as subforms (the mainform is the first element)
'sf' used outside of binding context.
555 }
556
557 subform (sf, action = 'save') {
558 let id = sf559 const deleteAll = action == 'delete'
560 let sel
561 let oi
'sf' used outside of binding context.
566 let na
567 const cThis = this
568
569 if (sf == '') {570 id = 'nuBuilder4EditForm'
571 oi = -1
572 fk = ''
'sf' used outside of binding context.
581 oi = nuFORM.getCurrent().form_id
582 }
583 } else {
584 sel = "[id*='" + sf + "'][id*='nuRECORD']"585 table = $(sel).attr('data-nu-table')
586
587 const $sf = $('#' + sf)
'sf' used outside of binding context.
584 sel = "[id*='" + sf + "'][id*='nuRECORD']"
585 table = $(sel).attr('data-nu-table')
586
587 const $sf = $('#' + sf)588 oi = $sf.attr('data-nu-object-id')
589 fk = $sf.attr('data-nu-foreign-key-name')
590 pk = $sf.attr('data-nu-primary-key-name')
'sf' used outside of binding context.
610 let chk = $('#' + this.id).prop('checked')
611
612 THIS.children('[data-nu-data]').each(function () {
613 const children = cThis.subformCollectRecordChildren(this, sf, chk, deleteAll, V, E, F, C)614 chk = children.chk
615 V = children.V
616 E = children.E
Description
Variables should be used inside of their binding context.
This helps avoid difficult bugs with variable hoisting.
It is a bad practice to use var
declarations because variables declared using var
can be accessed in a function-wide scope.
They can even be accessed before declaration.
In such cases, their value would be undefined
because only declarations and not initializations are hoisted.
Bad Practice
function doIf() {
if (cond()) {
var build = true;
}
console.log(build);
}
function doIfElse() {
if (cond()) {
var build = true;
} else {
var build = false;
}
console.log(build)
}
Recommended
function doIf() {
let build;
if (cond()) {
build = true;
}
console.log(build);
}