I have a JavaScript code that looks like the excerpt below. At line,
this.orgBusinessKey = this.user.noaOrganisationList[0].businessKey;
will the this scope contain the user instance passed as parameter to the constructor?
I've read this post on this scope, but, according to my belief, at setAdmin this refers to MyClass which does not include (or does it?) the parameters like user passed to the constructor.
export interface IUser {
noaOrganisationList: IOrganisation[];
}
export interface IOrganisation {
id?: number;
name?: string;
businessKey: string;
}
export class MyClass {
orgBusinessKey: string = '';
constructor(public user: IUser)
{
this.setAdmin(user);
}
setAdmin(user: IUser): void {
if (user && user.noaOrganisationList && !_.isEmpty(user.noaOrganisationList)) {
this.orgBusinessKey = this.user.noaOrganisationList[0].businessKey;
}
}
}