Javascript Question and Answer
Javascript Question and Answer
41. <script language="javascript">
function x()
{
var qpt = "First come, first served";
var pattern = /first/gi;
document.write(qpt.match(pattern)[1]);
}
</script>
function x()
{
var qpt = "First come, first served";
var pattern = /first/gi;
document.write(qpt.match(pattern)[1]);
}
</script>
- first
- undefined
- First
- Error
43. In javascript, Which of the above Comments lines are used ?
- Only (d)
- Only (c)
- Either (c) or (d)
- Only (b)
44. <script language="javascript">
function x()
{
var s = "Give 100%!{[!!";
var pattern = /\W/g;
var output = s.match(pattern);
document.write(output);
}
</script>
function x()
{
var s = "Give 100%!{[!!";
var pattern = /\W/g;
var output = s.match(pattern);
document.write(output);
}
</script>
- ,%,!,{,[,!,!
- G,i,v,e,1,0,0
- Give 100
- Error
46. <script type="text/javascript" language="javascript">
var qpt="QualityPointTechnologies";
var result =qpt.lastIndexOf("l");
document.write(result);
</script>
var qpt="QualityPointTechnologies";
var result =qpt.lastIndexOf("l");
document.write(result);
</script>
- 3
- 18
- 17
- 19
47. <script language="javascript">
function x()
{
var qpt = "First come, first served";
var pattern = /first/g;
document.write(qpt.match(pattern)[1]);
}
</script>
function x()
{
var qpt = "First come, first served";
var pattern = /first/g;
document.write(qpt.match(pattern)[1]);
}
</script>
- first
- First
- undefined
- None of the above
48. <script language="javascript">
function sum(x)
{
function add(y)
{
return x+y;
}
return add;
}
function callme() { result=sum(5)(5); alert(result); }
</script>
If you call the function callme(), what will happen ?
function sum(x)
{
function add(y)
{
return x+y;
}
return add;
}
function callme() { result=sum(5)(5); alert(result); }
</script>
If you call the function callme(), what will happen ?
- 10
- Error in calling Function
- 5
- None of the above
49. Who invented the javascript programming language?
- Tennis Ritchie
- James Gosling
- Brendan Eich
50. <script type="text/javascript">
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
</script>
Can you write HTML tag inside the javascript ?
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
</script>
Can you write HTML tag inside the javascript ?
- No
- Yes
- Impossible