From cfdce4b2903be484e748562bdda7f06889bd2846 Mon Sep 17 00:00:00 2001 From: suman-saket <54411834+suman-saket@users.noreply.github.com> Date: Fri, 22 Oct 2021 22:26:32 +0530 Subject: [PATCH] 2 object Question Added --- code-snippets/objects.md | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/code-snippets/objects.md b/code-snippets/objects.md index dbb6bb3..5f3721b 100644 --- a/code-snippets/objects.md +++ b/code-snippets/objects.md @@ -62,5 +62,77 @@ console.log(TDK); --- +
  • + +**What will be the output?** + +```JS +let myName = 'Sunny'; +let groupName = myName; + +myName = 'DevKode'; +console.log(groupName); + + +const obj1 = { + id:1, + name:"Sunny", +} + +const obj2 = obj1; +obj2.name = 'DevKode'; +console.log(obj1); +``` + +- A: `Sunny , { id: 1, name: 'Sunny' }` +- B: `DevKode,{ id: 1, name: 'Sunny' }` +- C: `DevKode,{ id: 1, name: 'DevKode' }` +- D: `Sunny,{ id: 1, name: 'DevKode' }` + +
    +
    +Answer +

    + +#### Option: D + +

    +
    +
  • + +--- + +
  • + +**What will be the output?** + +```JS + function greet(person) { + if (person == { name: 'Narendra Modi' }) { + return 'hey Narendra Modi' + } else { + return 'hey Donald Trump' + } +} + +console.log(greet({ name: 'amy' })) +``` + +- A: `hey Narendra Modi` +- B: `hey Donald Trump` + +
    +
    +Answer +

    + +#### Option: B + +

    +
    +
  • + +--- +