❗️Что будет на выходе:
Ответ:['Alice', undefined, true, undefined]
JavaScript test | #JavaScript & Max
const user = {
profile: {
name: 'Alice',
social: null,
getDetails() {
return { verified: true };
}
}
};
const result = [
user?.profile?.name,
user?.profile?.social?.handle,
user.profile.getDetails?.()?.verified,
user?.nonExistent?.property
];
console.log(result);
Ответ:
JavaScript test | #JavaScript & Max
❗️Что будет на выходе:
Ответ:Hello, I'm Alice Hello, I'm undefined Goodbye from undefined
JavaScript test | #JavaScript & Max
const person = {
name: 'Alice',
greet() {
return `Hello, I'm ${this.name}`;
},
farewell: () => `Goodbye from ${this.name}`
};
const greetFn = person.greet;
const farewellFn = person.farewell;
console.log(person.greet());
console.log(greetFn());
console.log(farewellFn());
Ответ:
JavaScript test | #JavaScript & Max