‘Undefined’ is the property of the global object. If you don’t assign any value to a variable is of type ‘undefined’. A code also return the undefined value when the evaluated variable doesn’t have any assigned value.
Example:
function test(t) {
if (t === undefined) {
console.log(t.tt)
}
return t;
}var a;
You need to make sure that which ever variables throws undefined error, has an assigned value.
function test(t) {
if (t === undefined) {
console.log(t)
}
return t;
}var a=10;
Now, in your case, issue seems to be with:
Constant.Units.forEach(function(item){
this.Units.push(item);
});
You are missing arrow in the call syntax. try:
Constant.Units.forEach((item) => {
this.Units.push(item);
});
For more details on it:
JavaScript Function Definitions[
^]
Quote:
Arrow functions do not have their own this. They are not well suited for defining object methods.