Modern Application Development II, Quiz 1
Consider the following JavaScript code. What will be logged on to the console once the code is executed?
function checkThis() { return this.name}const Obj1 = { name: 'Obj1', checkThis: checkThis,}const Obj2 = { name: 'Obj2', checkThis: checkThis,}console.log(Obj2.checkThis(), Obj1.checkThis.call(Obj2))Consider the following JavaScript code. What will be logged on to the console once the code is executed? function checkThis() { return this.name } const Obj1 = { name: 'Obj1', checkThis: checkThis, } const Obj2 = { name: 'Obj2', checkThis: checkThis, } console.log(Obj2.checkThis(), Obj1.checkThis.call(Obj2)) Consider the following JavaScript code. What will be logged on to the console once the code is executed? const stateManager = function () { let defaultState = false function alterState() { defaultState = !defaultState } return { currentState() { return defaultState }, changeState() { alterState() }, } } const sm1 = stateManager() sm1.changeState() const sm2 = stateManager() console.log(sm1.currentState(), sm2.currentState()) Consider the following JavaScript code. What will be logged on to the console once the code is executed? const player = { name: 'Rohit', state: 'Maharastra', } const batsman = Object.create(player) console.log(batsman.name)