Single Choice Question

  1. About the naming rules of identifier, which following statement is NOT correct
    1. Start with a letter, underscore or dollar sign.
    2. Can not start with a number.
    3. Only contain alphanumeric characters (A-z, 0-9) space and underscores.
    4. cannot be a JavaScript keyword or a JavaScript reserved word.
  2. Which is the correct way to declare a constant in JavaScript?
    1. var x = 5;
    2. let x = 5;
    3. const x = 5;
    4. int x = 5;
  3. What is the result of "1 + '2'"?
    1. 3
    2. 12
    3. NaN
    4. Error
  4. What is the result of "2 + '1'"?
    1. 3
    2. 21
    3. NaN
    4. Error
  5. Which is the correct name of a variable
    1. var
    2. myCar
    3. student name
    4. 3days
  6. Which is not the reserved keyword in JavaScript?
    1. int
    2. let
    3. const
    4. function
  7. Which is the wrong way to declare a variable in JavaScript?
    1. let message;
    2. let message; message = "Hello";
    3. let message = "Hello";
    4. String message = "Hello";
  8. What is the result of "1/0"?
    1. NaN
    2. Infinity
    3. Error
    4. 0
  9. Which way to specify a string is NOT correct
    1. "Hello"
    2. 'Hello'
    3. `Hello`
    4. <Hello>
  10. Result of the code:"let a = 4; alert(`{a} + 2 = {a + 2}`)" is
    1. "4 + 2 = 6"
    2. "4 + 2 = 4 + 2"
    3. "{a} + 2 = {a + 2}"
    4. "4 + 2 = {4 + 2}"
  11. Result of the code:"let age;alert(age);" is
    1. undefined
    2. null
    3. NaN
    4. Error
  12. What is the result of "typeof {}"?
    1. object
    2. array
    3. string
    4. number
  13. What is the result of "typeof NaN"?
    1. NaN
    2. number
    3. object
    4. string
  14. What is the result of "typeof ()->{}"?
    1. function
    2. number
    3. object
    4. string
  15. What is the result of "Boolean("hello")"?
    1. true
    2. false
    3. NaN
    4. Error
  16. What is the result of "+true"?
    1. 1
    2. true
    3. NaN
    4. Error
  17. What is the result of "8%3"?
    1. 2
    2. 1
    3. 0
    4. NaN
  18. What is the result of code: "let counter = 0;counter++;++counter;alert(counter);"
    1. 2
    2. 1
    3. 3
    4. 0
  19. What is the result of code: "'2' > 1"
    1. Error
    2. true
    3. false
    4. NaN
  20. What is the result of "!true && 1 < 3"
    1. Error
    2. true
    3. false
    4. NaN
  21. What is the result of code: "let age = 20; alert((age > 18) ? true : false)"
    1. true
    2. false
    3. 20
    4. undefined
  22. What is the difference between "==" and "==="?
    1. Both "===" and "==" are same.
    2. "===" is used to compare the value and type of two variables, while "==" is used to compare the value of two variables.
    3. "===" is used to compare the value of two variables, while "==" is used to compare the value and type.
    4. "===" is only used to compare the type of two variables, while "==" is used to compare the value.
  23. What is the result of code: "let a = 5; let b = 6; let c = 7; alert(a < b < c);"
    1. true
    2. false
    3. Error
    4. NaN
  24. What is the correct syntax for referring to an external script called "xxx.js"?
    1. <script src="xxx.js"></script>
    2. <script href="xxx.js"></script>
    3. <script link="xxx.js"></script>
    4. <script ="xxx.js">
  25. How do you show the info: "Hello World" in a popup dialog?
    1. alert("Hello World");
    2. msg("Hello World");
    3. log("Hello World");
    4. info("Hello World");

True or False Question

  1. The "undefined" means the value of a variable that is not assigned yet.
  2. The "null" is used to be assigned to an object.
  3. If assign "{}" to an object, it will be an empty object.
  4. The function is callable object that executes a block of code.
  5. An array is a type of object used for storing multiple values in single variable.
  6. The typeof operator can be used to find out what type of data a variable or operand contains.
  7. The result of `"6"/"2"` is 3.
  8. The result of `1 + '2'` is 3.
  9. The result of `2 + '1'` is 3.
  10. The result of x in `let x = (1 && 2) ?? 3;` is 3.
  11. Comparison operators:'===' compares the values and types of two operands.
  12. Result of `(!false)&&(5==="5")||(34>-34)` is false

Definition of Term

  1. Reserved Keywords
  2. Variable
  3. Constant
  4. Identifier
  5. Operator
  6. NaN
  7. null
  8. undefined

Short Answer

  1. What are the rules of naming identifiers?
  2. What are the suggestion for naming identifiers?
  3. Compare with variables and constants in JavaScript
  4. List the major data types of JavaScript.
  5. What are the basic rules of the operator precedence in JavaScript?