Q. What does the subexpression /java(script)?/ result in ?

  • (A) It matches “java” followed by the optional “script”
  • (B) It matches “java” followed by any number of “script”
  • (C) It matches “java” followed by a minimum of one “script”
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) It matches “java” followed by the optional “script”
Explanation: The subexpression /java(script)?/ matches “java” followed by the optional “script”.

Q. What is the most essential purpose of parantheses in regular expressions ?

  • (A) Define pattern matching techniques
  • (B) Define subpatterns within the complete pattern
  • (C) Define portion of strings in the regular expression
  • (D) All of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (B) Define subpatterns within the complete pattern
Explanation: When a regular expression is successfullyy matched against a target string, it is possible to extract the portions of the target string that matched any particular paranthesized subpattern. The essential purpose of parantheses in regular expressions is to define subpatterns within the complete pattern.

Q. The method that performs the search-and-replace operation to strings for pattern matching is

  • (A) searchandreplace()
  • (B) add()
  • (C) edit()
  • (D) replace()
πŸ’¬ Discuss
βœ… Correct Answer: (B) add()
Explanation: The replace() method performs a search-and-replace operation. It takes a regular expression as its first argument and a replacement string as its second argument.

Q. What would be the result of the following statement in JavaScript using regular expression methods ?

  • (A) Returns [“123″”456″”789”]
  • (B) Returns [“123″,”456″,”789”]
  • (C) Returns [1,2,3,4,5,6,7,8,9]
  • (D) Throws an exception
πŸ’¬ Discuss
βœ… Correct Answer: (B) Returns [“123″,”456″,”789”]
Explanation: The split() method can take regular expressions as its arguments. The split() method generally breaks the string on which it is called into an array of substrings, using the argument as a separator.

Q. The Crockford’s subset doesnot include which function in JavaScript?

  • (A) eval()
  • (B) coeval()
  • (C) equal()
  • (D) equivalent()
πŸ’¬ Discuss
βœ… Correct Answer: (A) eval()
Explanation: The Crockford’s subset does not include the with and continue statements or the eval() function. It defines functions using function definition expressions only and does not include the function definition statement.

Q. Why does JavaScript subset disallow == and !=?

  • (A) It uses bitwise checking
  • (B) It uses === and !== instead
  • (C) It uses equals() and notequals() instead
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (B) It uses === and !== instead
Explanation: The subset does not include the comma operator, the bitwise operators, or the ++ and — operators. It also disallows == and != because of the type conversion they perform, requiring use of === and !== instead.

Q. The maximum number of global symbols a module can define is

  • (A) 2
  • (B) 3
  • (C) 1
  • (D) 4
πŸ’¬ Discuss
βœ… Correct Answer: (C) 1
Explanation: Generally, the various modules are allowed to run in the pristine (or near pristine) environment that it expects. The modules should minimize the number of global symbols they define – ideally, no module should define more than one.

Q. To define each of the set classes as a property of the sets object (namespace) for the module, the statement is

  • (A) sets = sets.AbstractEnumerableSet.extend();
  • (B) sets.SingletonSet = sets.AbstractEnumerableSet.extend(...);
  • (C) sets.SingletonSet = sets.extend(...);
  • (D) sets = sets.extend(...);
πŸ’¬ Discuss
βœ… Correct Answer: (B) sets.SingletonSet = sets.AbstractEnumerableSet.extend(...);
Explanation: The sets object is the namespace for the module, and we define each of the set classes as a property of this object.

Q. Consider the following statement
var Set = sets.Set;
var s = new Set(1,2,3);
What could be the efficiency quotient of the above two statements ?

  • (A) The programmer imports at once the frequently used values into the global namespace
  • (B) There is no efficiency quotient, the programmer tries to make it inefficient
  • (C) The programmer needs to import the Sets everytime he wants to use it
  • (D) All of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) The programmer imports at once the frequently used values into the global namespace
Explanation: A programmer can import frequently used values into the global namespace. A programmer who was going to make frequent use of the Set class from the sets namespace might import the class like that.

Q. The scope of a function is also called as

  • (A) The function’s scope
  • (B) Module function
  • (C) Modulated function
  • (D) Private function
πŸ’¬ Discuss
βœ… Correct Answer: (B) Module function
Explanation: The scope of a function can be used as a private namespace for a module. Therefore, the scope of a function is called a module function.