Q. A __________ will be visible only within a function where it is defined.

  • (A) global variables
  • (B) local variable
  • (C) Both A and B
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (B) local variable

Q. What will be the output of the following JavaScript code?

Code:
< p id="demo">< /p>
< script>
var a = 63.786;
document.getElementById ("demo").innerHTML =a.toFixed(0)
< /script>
  • (A) 63.77
  • (B) 64
  • (C) 63
  • (D) 63.8
πŸ’¬ Discuss
βœ… Correct Answer: (B) 64
Explanation:

Let's solve it carefully.

You have this JavaScript code:

<p id="demo"></p>
<script>
var a = 63.786;
document.getElementById("demo").innerHTML = a.toFixed(0);
</script>
  • a.toFixed(0) means: round a to 0 decimal places.
  • a = 63.786
  • Rounding 63.786 to 0 decimal places gives 64.

So the correct answer is:

(B) 64

Q. What will be the output of the following JavaScript code?

Code:
< p id="demo">< /p>
< script>
var a = "10"; var b = "10"; var c = a * b; document.getElementById ("demo").innerHTML = c; < /script>
  • (A) 10
  • (B) 100
  • (C) 1000
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 100

Q. What will be the output of the following JavaScript code?

Code:
< p id="demo">< /p>
< script>
var a = 20;
var b = "30";
document.getElementById ("demo").innerHTML = x + y;
< /script>
  • (A) 50
  • (B) 20+30
  • (C) 2030
  • (D) error
πŸ’¬ Discuss
βœ… Correct Answer: (C) 2030

Q. What is the code required to delete all weight tags?

  • (A) delete pt..weight;
  • (B) delete pt;
  • (C) delete pt.element[all];
  • (D) delete weight(pt).all;
πŸ’¬ Discuss
βœ… Correct Answer: (A) delete pt..weight;

Q. Which of the following is the descendant operator?

  • (A) ..
  • (B) ...
  • (C) *
  • (D) @
πŸ’¬ Discuss
βœ… Correct Answer: (B) ...

Q. What is the code to be used to trim whitespaces?

  • (A) let trimmed = for(l in lines));
  • (B) let trimmed = l.trim();
  • (C) let trimmed = (trim(l));
  • (D) let trimmed = (l.trim() for (l in lines));
πŸ’¬ Discuss
βœ… Correct Answer: (D) let trimmed = (l.trim() for (l in lines));

Q. What does the following JavaScript code snippet do?

Code:
data.sort(function(a,b),b-a);
  • (A) Sort in reverse numerical order
  • (B) Sort in reverse alphabetical order
  • (C) Sort in the chronological order
  • (D) Sort in the alphabetical order
πŸ’¬ Discuss
βœ… Correct Answer: (A) Sort in reverse numerical order

Q. What convenience does the following JavaScript code snippet provide?

Code:
let suc = function(a) a+1, yes = function() true, no = function() false;
  • (A) Shorthand expression
  • (B) No convenience
  • (C) Modular behaviour
  • (D) Functional behaviour
πŸ’¬ Discuss
βœ… Correct Answer: (D) Functional behaviour

Q. The ________ operator is used to create an instance of an object.

  • (A) new
  • (B) find
  • (C) self
  • (D) this
πŸ’¬ Discuss
βœ… Correct Answer: (A) new