NEW
Font size
WorksheetsDay 3 - Dom Manipulation
Total questions: 20
Worksheet time: 10mins
What will be printed in the console on execution of the following JS code:
var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
var myArr= array.filter(v => v % 3 === 0);
console.log(myArr);
myArr
[3, 6, 9, 12, 15]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
[1, 2, 4, 5, 7, 8, 10, 11, 13, 14]
What will be printed in the console on execution of the following JS code:
var array = [2, 4, 6, 7, 8, 10];
var myArr= array.filter(v => v / 2 === 0);
console.log(myArr);
myArr
[2, 4, 6, 7, 8, 10]
[2, 4, 6, 8, 10]
[7]
What will be printed in the console on execution of the below code?
var materials = [
'Hydrogen',
'Helium',
'Lithium',
'Beryllium'
];
console.log(materials.map (material => material.length));
[8, 6, 7, 9]
4
[4]
8, 6, 7, 9
var val = "JavaScript String"
splittedVal = val.split('a',2)
console.log(splittedVal);
[ 'J', 'v' ]
[ 'J' ,'v','Script']
[ 'J', 'v', 'Script String' ]
[ 'JavaScript String' ]
Which built-in method combines the text of two strings and returns a new string?
append()
concat()
attach()
None of the above.
Which of the following function of String object returns the character at the specified index?
charAt()
charCodeAt()
concat()
indexOf()
The primary purpose of the array map() function is that it
maps the elements of another array into itself
passes each element of the array and returns the necessary mapped elements
passes each element of the array on which it is invoked to the function you specify, and returns an array containing the values returned by that function
None of the mentioned
The method or operator used to identify the array is
isarrayType()
==
===
typeof
The function definitions in JavaScript begins with
Identifier and Parantheses
Return type and Identifier
Return type, Function keyword, Identifier and Parantheses
Identifier and Return type
A collection of elements of the same data type which may either in order or not, is called _____.
String
Array
Serialized Object
Object
What will be the output obtained by "shift ()" in the given code of JavaScript?
var a =[]; a.unshift(5); a.unshift(22); a.shift(); a.unshift(3,[4,5]); a.shift(); a.shift(); a.shift();
Exception is thrown
[4,5]
[3,4,5]
5
var values=["Three","two","one"];
var ans=values.shift();
console.log(ans);
["two","one"];
Three
["Three","two","one"];
two one
var values=[4,5,6,7]
var ans=values.slice(1);
console.log(ans);
[5, 6, 7]
5,6,7
[4,5, 6, 7]
[]
Javascript string using double quotes is exactly the same as a string using single quotes?
True
False
var a = 'Java';
var b = 'Script';
var c = a/b;
console.log(c);
JavaScript
Java/Script
NaN
undefined
Find output of below Javascript addition code
console.log("1 plus 1 is " + 1 + 1);
2
1 plus 1 is 2
1 plus 1 is 11
1 plus 1 is 1 + 1
In JavaScript, Arrays are data type. State True or False
True
False
If para1 is the DOM object for a paragraph, what is the correct syntax to change the text within the paragraph?
para1="New Text"
para1.innerText="New Text";
para1.firstChild.nodeValue= "New Text";
para1.nodeValue="New Text";
Consider the following code snippet
const pi=3.14;
var pi=4;
console.log(pi);
What will be the output for the above code snippet?
This will flash an error
Prints 4
Prints 3.14
Ambiguity
The pop() method of the array does which of the following task ?
decrements the total length by 1
increments the total length by 1
prints the first element but no effect on the length
updates the element
