Modern Application Development II, Quiz 2
Consider the below javascript program.
var first = 30const obj1 = { first: 50, second: () => { console.log("Value:", this.first); }}
const obj2 = { first: 80, second: function () { console.log("Value:", this.first); this.second(); }}
obj2.second.call(obj1);What will be the output of the program, if executed in a REPL environment?
Consider the below javascript program. var first = 30 const obj1 = { first: 50, second: () => { console.log("Value:", this.first); } } const obj2 = { first: 80, second: function () { console.log("Value:", this.first); this.second(); } } obj2.second.call(obj1); What will be the output of the program, if executed in a REPL environment? Consider the below JavaScript code. function isValidAge(age) { return !(age > 18) } const validAgeParams = { voter_id: 123, constituency: 'New Delhi' } const teenageParams = { age_criteria: '<18', } let some_value; console.log( isValidAge(some_value) ? { 'name': 'ABC', ...(!isValidAge(19) && validAgeParams) } : { 'name': 'XYZ', ...(isValidAge(19) && teenageParams) } ); What will be the output of the above program, assuming the value of the variable “some\_value” is less than 18? Consider the below JavaScript program. const promise1 = new Promise((resolve, reject) => { setTimeout(() => { resolve('First promise resolved'); }, 1000); }); promise1 .then((result) => { console.log(result); return new Promise((resolve, reject) => { setTimeout(() => { resolve('Second promise resolved'); }, 3000); }); }) .then((result) => { console.log(result); return new Promise((resolve, reject) => { setTimeout(() => { reject('Third promise resolved'); }, 3000); }); }) .then((result) => { console.log(result); }) .catch((error) => { console.log("Promise chain interrupted. Reason:", error); }); What will be the output of the above program, if executed?