|
| 1 | +// Question: What is typeof [] |
| 2 | +// Answer: Object. Actually Array is derived from Object. If you want to check array use Array.isArray(arr) |
| 3 | + |
| 4 | +// Question: What is typeof arguments |
| 5 | +// Answer: Object. arguments are array like but not array. it has length, can access by index but can't push pop, etc. |
| 6 | + |
| 7 | +// Question: What is the value of typeof null |
| 8 | +// Answer: "object" |
| 9 | + |
| 10 | +// Question: What is console.log(true+false) |
| 11 | +// Answer: 1 here true -->> 1 & false -->> 0 then 1 + 0 -->> 1 |
| 12 | + |
| 13 | +// Question: What is 2+true |
| 14 | +// Answer: 3. The plus operator between a number and a boolean or two boolean will convert boolean to number. Hence, true converts to 1 and you get result of 2+1 |
| 15 | + |
| 16 | +// Question: What is "2"+true |
| 17 | +// Answer: 2true here string concatination happer "2"+"true" -->> 2true |
| 18 | + |
| 19 | +// Question: What is the value of -'34'+10 |
| 20 | +// Answer: -24. minus(-) in front of a string is an unary operator that will convert the string to a number and will make it negative. Hence, -'34' becomes, -34 and then plus (+) will perform simple addition as both the operands are number. |
| 21 | + |
| 22 | +// Question: What is the value of +'dude' |
| 23 | +// Answer: NaN. The plus (+) operator in front of a string is an unary operator that will try to convert the string to number. Here, JavaScript will fail to convert the "dude" to a number and will produce NaN. |
| 24 | + |
| 25 | +// Question: If you have var y = 1, x = y = typeof x; What is the value of x? |
| 26 | +// Answer: "undefined" |
| 27 | + |
| 28 | +// Question: for var a = (2, 3, 5); what is the value of a? |
| 29 | +// Answer: 5. The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand. ref: MDN |
| 30 | + |
| 31 | +// Question: for var a = (1, 5 - 1) * 2 what is the value of a? |
| 32 | +// Answer: 8 |
| 33 | + |
| 34 | +// Question: What is the value of !'bang' |
| 35 | +// Answer: false. ! is NOT. |
| 36 | + |
| 37 | +// Question: What is the value of parseFloat('12.3.4') |
| 38 | +// Answer: 12.3 |
| 39 | + |
| 40 | +// Question: What is the value of Math.max([2,3,4,5]); |
| 41 | +// Answer: NaN |
| 42 | + |
| 43 | +// Question: typeof(NaN) |
| 44 | +// Anwser:"number" |
| 45 | + |
| 46 | +// Question:null == undefined |
| 47 | +// Answer: true |
| 48 | + |
| 49 | +// Question: If var a = 2, b =3 what would be value of a && b |
| 50 | +// Answer: 3 |
| 51 | + |
| 52 | +// Question: What is -5%2 |
| 53 | +// Answer:-1. the result of remainder always get the symbol of first operand |
| 54 | +====================================================================================================================================================================== |
1 | 55 | let a = []; |
2 | 56 | let b = []; |
3 | 57 | console.log(a==b); //false |
|
0 commit comments