Hello all,
I am experiencing two strange behavior when using the "let" definitions.
I have been trying to create simple examples running them in the shell
but I have been unable to reproduce it. I am hoping someone can give me
some direction on how to proceed.
Issue #1
The code below generates an error when the if statement has braces
around the statement. It complains that select[0] is not defined:
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "0.0"
from undefined. If the braces are removed then it works as expected.
...
let select = mkSelect(sel_list, table, obj, where_list);
...
let order_str;
if(struct && struct.orderby) {
order_str = mkOrderBy(struct.orderby, obj, select[0]);
}
...
Issue #2
When using "let where_list", the variable is not the same inside the
braces. So running this generates:
Inside: 2
org.mozilla.javascript.EcmaError: TypeError: Cannot read property
"length" from undefined
I switch it to use "var" instead and it works as expected.
...
let where_list = undefined;
if(params.WHERE) {
if(params.WHERE.constructor.name == 'String') {
where_list = [];
let lst = params.WHERE.split('|');
for(let i=0;i<lst.length;i++) {
...
where_list.push(fld);
}
} else if(params.WHERE.constructor.name == 'Array') {
where_list = params.WHERE;
}
} else {
if(struct && struct.where) {
where_list = struct.where;
debug("Inside: " where_list.length);
}
}
debug("Outside: " + where_list.length);
...
Also, using let (where_list) {...} enclosing everything works as well.
Thanks
Edwin S. Ramirez
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino