|
3 | 3 | </div>
|
4 | 4 |
|
5 | 5 | <ol>
|
| 6 | + |
6 | 7 | <li>
|
7 | 8 |
|
8 | 9 | **What will be the Output??**
|
@@ -76,4 +77,188 @@ TeamDevKode ()
|
76 | 77 |
|
77 | 78 | ---
|
78 | 79 |
|
| 80 | +<li> |
| 81 | + |
| 82 | +**What is the output ?** |
| 83 | + |
| 84 | +```JS |
| 85 | +const animal = { |
| 86 | + animal_name: "cat", |
| 87 | + action: function () { |
| 88 | + console.log(`${this.animal_name} is doing action`); |
| 89 | + } |
| 90 | +}; |
| 91 | + |
| 92 | +setTimeout(animal.action, 1000); |
| 93 | + |
| 94 | +``` |
| 95 | + |
| 96 | +- A: `cat is doing action` |
| 97 | +- B: `undefined is doing action` |
| 98 | +- C: `null is doing action` |
| 99 | +- D: `error` |
| 100 | + |
| 101 | +<br/> |
| 102 | + |
| 103 | +<details> |
| 104 | +<summary><b>Answer</b></summary> |
| 105 | +<p> |
| 106 | + |
| 107 | +#### Option: B |
| 108 | + |
| 109 | +</p> |
| 110 | +</details> |
| 111 | + |
| 112 | +</li> |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +<li> |
| 117 | + |
| 118 | +**What is the output ?** |
| 119 | + |
| 120 | +```JS |
| 121 | +const animal = { |
| 122 | + animal_name: "cat", |
| 123 | + action: function () { |
| 124 | + console.log(`${this.animal_name} is doing action`); |
| 125 | + } |
| 126 | +}; |
| 127 | + |
| 128 | +setTimeout(function () { |
| 129 | + animal.action(); |
| 130 | +}, 1000); |
| 131 | + |
| 132 | +``` |
| 133 | + |
| 134 | +- A: `cat is doing action` |
| 135 | +- B: `undefined is doing action` |
| 136 | +- C: `null is doing action` |
| 137 | +- D: `error` |
| 138 | + |
| 139 | +<br/> |
| 140 | + |
| 141 | +<details> |
| 142 | +<summary><b>Answer</b></summary> |
| 143 | +<p> |
| 144 | + |
| 145 | +#### Option: A |
| 146 | + |
| 147 | +</p> |
| 148 | +</details> |
| 149 | + |
| 150 | +</li> |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +<li> |
| 155 | + |
| 156 | +**What is the output ?** |
| 157 | + |
| 158 | +```JS |
| 159 | +const animal = { |
| 160 | + animal_name: "cat", |
| 161 | + action: function () { |
| 162 | + console.log(`${this.animal_name} is doing action`); |
| 163 | + } |
| 164 | +}; |
| 165 | + |
| 166 | +let func = animal.action.bind(animal); |
| 167 | +setTimeout(func, 1000); |
| 168 | + |
| 169 | +``` |
| 170 | + |
| 171 | +- A: `null is doing action` |
| 172 | +- B: `undefined is doing action` |
| 173 | +- C: `cat is doing action` |
| 174 | +- D: `error` |
| 175 | + |
| 176 | +<br/> |
| 177 | + |
| 178 | +<details> |
| 179 | +<summary><b>Answer</b></summary> |
| 180 | +<p> |
| 181 | + |
| 182 | +#### Option: C |
| 183 | + |
| 184 | +</p> |
| 185 | +</details> |
| 186 | + |
| 187 | +</li> |
| 188 | + |
| 189 | +--- |
| 190 | + |
| 191 | +<li> |
| 192 | + |
| 193 | +**What is the output ?** |
| 194 | + |
| 195 | +```JS |
| 196 | +function getFunc() { |
| 197 | + let value = "Hey !"; |
| 198 | + |
| 199 | + let func = new Function("console.log(value)"); |
| 200 | + |
| 201 | + return func; |
| 202 | +} |
| 203 | + |
| 204 | +getFunc()(); |
| 205 | + |
| 206 | +``` |
| 207 | + |
| 208 | +- A: `Hey !` |
| 209 | +- B: `error: value is not defined` |
| 210 | +- C: `null` |
| 211 | + |
| 212 | +<br/> |
| 213 | + |
| 214 | +<details> |
| 215 | +<summary><b>Answer</b></summary> |
| 216 | +<p> |
| 217 | + |
| 218 | +#### Option: B |
| 219 | + |
| 220 | +</p> |
| 221 | +</details> |
| 222 | + |
| 223 | +</li> |
| 224 | + |
| 225 | +--- |
| 226 | + |
| 227 | +<li> |
| 228 | + |
| 229 | +**What is the output ?** |
| 230 | + |
| 231 | +```JS |
| 232 | +function getFunc() { |
| 233 | + let value = "Hello Friends !"; |
| 234 | + let func = () => { |
| 235 | + alert(value); |
| 236 | + }; |
| 237 | + return func; |
| 238 | +} |
| 239 | + |
| 240 | +getFunc()(); |
| 241 | + |
| 242 | +``` |
| 243 | + |
| 244 | +- A: `Hey !` |
| 245 | +- B: `error: value is not defined` |
| 246 | +- C: `Hello Friends !` |
| 247 | +- D: `null` |
| 248 | + |
| 249 | +<br/> |
| 250 | + |
| 251 | +<details> |
| 252 | +<summary><b>Answer</b></summary> |
| 253 | +<p> |
| 254 | + |
| 255 | +#### Option: C |
| 256 | + |
| 257 | +</p> |
| 258 | +</details> |
| 259 | + |
| 260 | +</li> |
| 261 | + |
| 262 | +--- |
| 263 | + |
79 | 264 | </ol>
|
0 commit comments