Skip to content

Commit 6f69968

Browse files
committed
adding tricky questions
1 parent a6f5ebc commit 6f69968

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#### Q - What will be the output of the below code and why
2+
3+
```js
4+
const number = 1
5+
const result = (function (number) {
6+
delete number
7+
return number
8+
})(10)
9+
console.log(result)
10+
```
11+
12+
#### Ans - The output of the above code is 10
13+
14+
#### Explanations
15+
16+
In this code, we are passing the value 10 as the input to the function. But again inside the function number is just a local primitive type of variable so delete will not make any changes to the number and the value 10 passed to the function will be returned from the function.

0 commit comments

Comments
 (0)