Javascript (JS) Shorthand Functions MCQ

This section focuses on the "Javascript Shorthand Functions". These Multiple Choice Questions (mcq) should be practiced to improve the Javascript skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. What convenience does the following JavaScript code snippet provide?
let suc = function(a) a+1, yes = function() true, no = function() false;

A. Functional behaviour
B. Modular behaviour
C. No convenience
D. Shorthand expression

View Answer


2. What does the following JavaScript code snippet do?
data.sort(function(a,b),b-a);

A. Sort in the alphabetical order
B. Sort in the chronological order
C. Sort in reverse alphabetical order
D. Sort in reverse numerical order

View Answer


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

A. let trimmed = (l.trim() for (l in lines));
B. let trimmed = (trim(l));
C. let trimmed = l.trim();
D. let trimmed = for(l in lines));

View Answer


4. Which of the following is the descendant operator?

A. ..
B. ...
C. *
D. @

View Answer


5. What is the code required to delete all “weight” tags?

A. delete weight(pt).all;
B. delete pt.element[all];
C. delete pt;
D. delete pt..weight;

View Answer


6. What will be the output of the following JavaScript code?
< p id="demo">< /p>
< script>
var a = 20;
var b = "30";
var c = a + b;
document.getElementById ("demo").innerHTML = c;
< /script>

A. 50
B. 20+30
C. 2030
D. error

View Answer


7. What will be the output of the following JavaScript 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

View Answer


8. What will be the output of the following JavaScript code?
< p id="demo">< /p>
< script>
var a = "10"; var b = "10"; var c = a * b; document.getElementById ("demo").innerHTML = c; < /script>

A. 100
B. 10
C. 1010
D. error

View Answer


9. What will be the output of the following JavaScript code?
< p id="demo">< /p>
< script>
var a = "10";
var b = "10";
var c = a % b;
document.getElementById ("demo").innerHTML = c;
< /script>

A. true
B. 1
C. 0
D. false

View Answer


10. What will be the output of the following JavaScript code?
< p id="demo">< /p>
< script>
var a = 63.786;
document.getElementById ("demo").innerHTML =a.toFixed(0)
< /script>

A. 63.8
B. 63
C. 64
D. 63.77

View Answer






Also check :


Discussion


* You must be logged in to add comment.