Understanding syntax and language fundamentals is crucial for mastering code structure and flow. This guide focuses on core concepts like variables, data types, operators, and comments, laying the groundwork for dynamic programming.
Multiple Choice Questions
Variables (let, const, var)
Which keyword is used to declare a variable that can be reassigned?
A) const
B) var
C) let
D) both B and C
What is the main difference between let and const?
A) let allows reassignment, while const does not.
B) const allows reassignment, while let does not.
C) Both cannot be reassigned.
D) const can only be used in functions.
If you declare a variable with var, where is it accessible?
A) Only within the function scope
B) Only in the block it is defined
C) Globally, if declared outside a function
D) Only inside a loop
Which variable declaration keyword introduces block-level scoping?
A) var
B) let
C) const
D) both B and C
What happens if you try to reassign a const variable?
A) It reassigns successfully.
B) An error is thrown.
C) The variable resets to null.
D) It gets reassigned without errors.
Data Types (String, Number, Boolean, Null, Undefined, Symbol)
Which data type is used to represent text?
A) String
B) Boolean
C) Number
D) Symbol
What will be the result of typeof undefined?
A) null
B) object
C) undefined
D) boolean
Which of the following represents a Boolean value?
A) “true”
B) 1
C) true
D) “false”
Which data type would NaN belong to?
A) Boolean
B) String
C) Number
D) Undefined
Which of the following statements is true?
A) Symbols are used to create unique identifiers.
B) Numbers include both integer and string types.
C) Undefined and null are of the same data type.
D) A String can be only a single character.
What does typeof null return in JavaScript?
A) undefined
B) null
C) object
D) string
Which data type is primarily used to represent a true or false condition?