Topic

Basic JavaScript

Practice related MCQ quizzes and improve step by step.

Quizzes in Basic JavaScript

What will be output in console:

var animals = ['Tiger', 'Lion', 'Camel', 'Cow', 'Duck'];
console.log(animals.slice(2, 4));
Correct answer(s):
    • Array ["Camel", "Cow"]

What is going to display with this js code:

var myArray = ['a', 'b', 'c'];
 console.log(myArray[-1]);
Correct answer(s):
    • undefined

Which of these lines of code would replace the content of a webpage with “Saaaaaakib”?

Correct answer(s):
    • document.body.innerHTML = "Saaaaaakib";

When you’re writing JS on a webpage, what is the name of the global variable that represents the DOM?

Correct answer(s):
    • document

When used as a constructor, like new MyFunction(), the value of this will be a brand new object provided by the JavaScript runtime. If we don’t explicitly return anything from that function, this will be considered its return value.

Correct answer(s):
    • true

What does the below line do considering it as the first line in your javascript file:

(function(){
    alert(this);
})();
Correct answer(s):
    • I will see an alert with not null value