Question: What will be the output of console.log(5 - "2")?
Answer: The output will be 3. JavaScript will perform the subtraction operation, converting the string "2" to a number.
Question: Given the variable bool = true, what will be the output of console.log(typeof bool)?
Answer: The output will be "boolean". The typeof operator will return the data type of the variable, which is boolean in this case.
Question: What will be the output of console.log(null)?
Answer: The output will be null.
Question: What will be the output of console.log(typeof [1, 2, 3]?
Answer: The output will be "object". In JavaScript, arrays are considered objects.
Question: Given the object person = { name: "Alice", age: 30 }, what will be the output of console.log(person)?
Answer: The output will be an object representation of
person
: { name: 'Alice', age: 30 }.Question: What will be the output of console.log(undefined)?
Answer: The output will be undefined.
Question: If you have three variables x = 5, y = "2", and z = "3", what will be the output of console.log(x + y + z)?
Answer: The output will be "523". JavaScript will perform string concatenation.
Question: What will be the output of console.log(true + true)?
Answer: The output will be 2. In JavaScript,
true
is treated as 1 in numeric operations.Question: Given the variable arr = [1, 2, 3], what will be the output of console.log(arr)?
Answer: The output will be the array representation of arr: [1, 2, 3].
Question: What will be the output of console.log(typeof "hello")?
Answer: The output will be "string".
Question: What will be the output of console.log(5 - "2")?
Answer: The output will be 3. JavaScript will perform the subtraction operation, converting the string "2" to a number.
Question: Given the variable bool = true, what will be the output of console.log(typeof bool)?
Answer: The output will be "boolean". The typeof operator will return the data type of the variable, which is boolean in this case.
Question: What will be the output of console.log("2" * "3")?
Answer: The output will be 6. JavaScript will perform the multiplication operation, converting both strings "2" and "3" to numbers.