My Report

JavaScript Basic Online Test – 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

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

string  a = ”hi”;
string  b =”there”;
alert(a+b);

2. Consider the following JavaScript statements.

var text = "testing: 1, 2, 3"; // Sample text
var pattern = /\d+/g // Matches all instances of one or more digits

In order to check if the pattern matches with the string "text", the statement is ____________

3. Which of the operator is used to test if a particular property exists or not?

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

var  obj=
{
	length:20,
	height:35,
}
if (‘breadth' in obj === false) 
{
  	obj.breadth = 12;
}

console.log(obj.breadth);

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

<p id="demo"></p>
<script>
function myFunction() 
{
    document.getElementById("demo").innerHTML = Math.cbrt(125);
}
</script>

6. What will be the equivalent output of the following JavaScript code snippet?

x = ~-y;
w = x = y = z;
q = a?b:c?d:e?f:g; 

7. The expression of calling (or executing) a function or method in JavaScript is called ________

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

function output(option)
{
	return (option ?  “yes” :  “no”);
}
	bool ans=true;
console.log(output(ans));

9. The property of a primary expression is ____________

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

<p id="demo"></p>
<script>
function myFunction() 
{
    document.getElementById("demo").innerHTML = Math.acos(0.5);
}
</script>

11. Among the following, which one is a ternary operator?

12. “An expression that can legally appear on the left side of an assignment expression.” is a well known explanation for variables, properties of objects, and elements of arrays. They are called ___________

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

function height()
{	
    var  height = 123.56;
    var type = (height>=190) ? "tall" : "short";
    return type;
}

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

<p id="demo"></p>
<script>
function myFunction() 
{
    document.getElementById("demo").innerHTML = Math.abs(-7.25);
}
</script>

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

var string1 = ”123”;
var intvalue = 123;
alert( string1 + intvalue );

16. What kind of expression is “new Point(2,3)”?

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

function output(object)
{
	var place=object ? object.place : “Italy”;
	return “clean:”+ place;
}
console.log(output({place:India}));

18. A function definition expression can be called as __________


 

Start practicing “1000 MCQs on JavaScript”, and once you are ready, you can take tests on all topics by attempting our “JavaScript Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.