NEW
Font size
Worksheets24/01/2024
Total questions: 15
Worksheet time: 3mins
What is JavaScript primarily used for?
Database Management
Creating Dynamic Web Pages
Network Security
Graphic Designing
Which keyword is used to declare a constant variable in JavaScript?
let
const
var
constant
What is the purpose of the document.getElementById() function?
To get the value of an input field
To select an HTML element by its id
To create a new HTML element
To delete an HTML element
What is the purpose of the addEventListener method in JavaScript?
To change the style of an element
To create a new HTML element
To add an event handler to an element
To remove an element from the DOM
How do you declare a function expression in JavaScript?
function myFunction() {}
const myFunction = function() {}
let myFunction = () => {}
both b and c
What does the typeof operator return for an array
array
object
list
typeof doesn't work for arrays
In JavaScript, which loop is ideal for iterating over the elements of an array?
while
Do-while
for-in
for
Which keyword is used to exit a loop prematurely in JavaScript?
break
exit
return
end
What does the NaN value represent in JavaScript?
Not a Number
Negative And Null
Null or Negative
Not Any Number
How do you check if a variable is of type "string" in JavaScript?
typeof variable === 'string'
variable.type === 'string'
typeOf(variable) == 'string'
variable instanceof String
What is the difference between null and undefined in JavaScript?
They are interchangeable
null represents an empty or non-existent value, while undefined is the absence of a value
undefined represents an empty or non-existent value, while null is the absence of a value
There is no difference
What is the purpose of the querySelector() method in JavaScript?
To select the first element that matches a specified CSS selector
To create a new HTML element
To modify the style of an element
To remove an element from the DOM
What is the difference between a static method and an instance method in a class?
Static methods are called on instances, while instance methods are called on the class itself
Static methods are defined using the this keyword, while instance methods use self
Static methods are called on the class itself, while instance methods are called on instances
To remove an element from the DOMThere is no difference between static and instance methods
How do you inherit from multiple classes in JavaScript?
Using the inherits keyword
JavaScript does not support multiple inheritance
Using the mixins keyword
Using the extends keyword for each parent class
How do you check if a class has a particular method in JavaScript?
Using the methodExists operator
With the hasMethod function
By inspecting the prototype of the class
There is no direct way to check for a method
