290 var opt = document.createElement("option");
291 opt.text = '-- SELECT FROM LIST --';
292 opt.value = 'invalid';
293 el.options.add(opt);294
295 for (i=0;i<farmercodes.length;i++){
296 var opt = document.createElement("option");
289
290 var opt = document.createElement("option");
291 opt.text = '-- SELECT FROM LIST --';
292 opt.value = 'invalid';293 el.options.add(opt);
294
295 for (i=0;i<farmercodes.length;i++){
288 }
289
290 var opt = document.createElement("option");
291 opt.text = '-- SELECT FROM LIST --';292 opt.value = 'invalid';
293 el.options.add(opt);
294
287 el.removeChild(el.childNodes[0]);
288 }
289
290 var opt = document.createElement("option");291 opt.text = '-- SELECT FROM LIST --';
292 opt.value = 'invalid';
293 el.options.add(opt);
176 error: function(data, status){
177 msg = "";
178 for (prop in data){
179 msg += "property: " + prop + " value: [" + data[prop] + "]\n";180
181 }
182 console.log(msg);
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.
function doIf() {
if (cond()) {
var build = true;
}
console.log(build);
}
function doIfElse() {
if (cond()) {
var build = true;
} else {
var build = false;
}
console.log(build)
}
function doIf() {
let build;
if (cond()) {
build = true;
}
console.log(build);
}