JavaScript/ Sample Test,Sample questions

Question:
 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;

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

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

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

4.x = ~(-y); w = (x = (y = z)); q = (c?d:(e?f:g));

Posted Date:-2022-02-15 05:19:51


Question:
 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>

1.125

2.25

3.5

4.Error

Posted Date:-2022-02-15 05:37:47


Question:
 What will be the output of the following JavaScript code?

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

1. hi

2.there

3.hithere

4.undefined

Posted Date:-2022-02-15 05:24:48


Question:
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 ___________

1.Properties

2.Prototypes

3.Lvalue

4.Definition

Posted Date:-2022-02-15 05:16:47


Question:
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>

1.7.25

2.-7.25

3.7

4. -7

Posted Date:-2022-02-15 05:36:57


Question:
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>

1.1.01

2.1.047

3.1.00

4. 1.4

Posted Date:-2022-02-15 05:38:47


Question:
What will be the output of the following JavaScript code?

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

1.123.56

2.190

3.tall

4.short

Posted Date:-2022-02-15 05:22:21


Question:
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}));

1. clean:India

2.clean:Italy

3.error

4.undefined

Posted Date:-2022-02-15 05:36:05


Question:
What will be the output of the following JavaScript code?

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

1.Yes

2.No

3.Runtime error

4. Compilation error

Posted Date:-2022-02-15 05:21:04


More MCQS

Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!