diff --git a/README.md b/README.md index 96a2564..f0df4a6 100644 --- a/README.md +++ b/README.md @@ -712,3 +712,97 @@ console.log(Object.keys(arr)); **[:top: Scroll to Top](#javascript-output-based-interview-questions)** +**41. What will be the output** +```js +function modify(obj) { + obj.name = "Updated"; +} + +let person = { name: "Original" }; +modify(person); +console.log(person.name); + +function reassign(obj) { + obj = { name: "New Object" }; +} + +reassign(person); +console.log(person.name); +``` +
+ View Answer + +
+ +**[:top: Scroll to Top](#javascript-output-based-interview-questions)** + + +**42. What will be the output** +```js +let a={ x:1, y: {alpha:10,beta:20} }; +let b = {...a}; +b.x=101; +b.y.alpha=1001; +console.log(a.x); +console.log(a.y.alpha); +``` +
+ View Answer + +
+ +**[:top: Scroll to Top](#javascript-output-based-interview-questions)** + + +**43. What will be the output** +```js +console.log('Start'); + +setTimeout(() => { + console.log('setTimeout'); +}, 0); + +Promise.resolve().then(() => { + console.log('Promise'); +}); + +console.log('End'); +``` + +**44. What will be the output** +```js +console.log('Start'); + +setTimeout(() => { + console.log('setTimeout'); +}, 0); + +Promise.resolve().then(() => { + console.log('Promise'); +}); + +console.log('End'); +``` +
+ View Answer + +
+ +**[:top: Scroll to Top](#javascript-output-based-interview-questions)** \ No newline at end of file