Lets Fall Into Some JavaScript Question:
Topic 1: Data Types
Q1. What are the primitive data types available in JavaScript?
Answer :Number, String ,Boolean, Null, Undefined, Symbol, BigInt
Q2. What is the difference between null and undefined?
Answer:
null → intentional absence of a value.
undefined → variable declared but no value assigned.
Q3. Is JavaScript a statically typed or dynamically typed language? Why?
Answer:
Dynamically typed → variable types are determined at runtime, not declared explicitly.
Topic 2: Operations
Q1. What are the different types of operators in JavaScript?
Answer:
Arithmetic, Comparison, Logical, Assignment,Bitwise, Ternary (conditional), typeof, instanceof.
Q2. Explain the difference between == and ===.
Answer:
== → checks value after type coercion.
=== → checks value and type (strict equality).
Topic : Logical
Q1. What are the logical operators in JavaScript?
Answer:
=> && (AND)
=> || (OR)
=> ! (NOT)
Q2. What will this return?
console.log(true && false || !false);
Answer:
true && false → false
!false → true
false || true → true
Q3. What is the output of:
console.log(0 == false);
console.log(0 === false);
Answer:
0 == false → true (type coercion)
0 === false → false (different types)
Why?
It all comes down to the difference between:
== → loose equality
=== → strict equality
Now you have the dout , Why number turn into boolean .
Because in the ECMAScript spec:
When you compare Number and Boolean with ==,
JavaScript always converts the boolean to a number.
false → 0
true → 1
Then compares number with number.
That's all for today , It may help you to improve your knowledge .
Quotes Time :
“Don’t wait for opportunity. Create it.”
Top comments (0)