0% found this document useful (0 votes)
5 views4 pages

JavaScript Quiz: Test Your Knowledge

The document consists of a quiz on JavaScript covering various topics such as syntax, functions, and programming concepts. It includes multiple-choice questions that test knowledge on JavaScript operations, language characteristics, and coding practices. The questions range from basic syntax to specific functions and their outputs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

JavaScript Quiz: Test Your Knowledge

The document consists of a quiz on JavaScript covering various topics such as syntax, functions, and programming concepts. It includes multiple-choice questions that test knowledge on JavaScript operations, language characteristics, and coding practices. The questions range from basic syntax to specific functions and their outputs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Frontent Advanced

Module 01 - JavaScript

1. If you type the following code in the console window, what result will you get?

3 > 2 > 1 === false;

A. true
B. false
C. 1
D. NaN

2. JavaScript is a ___ -side programming language.

A. Client
B. Server
C. Both
D. None

3. Which of the following will write the message “Hello World!” in an alert box?

A. alertBox(“Hello World!”);
B. alert(Hello World!);
C. msgAlert(“Hello World!”);
D. alert(“Hello World!”);

4. How do you find the minimum of x and y using JavaScript?

A. min(x,y);
B. [Link](x,y)
C. [Link](xy)
D. min(xy);

5. If the value of x is 40, then what is the output of the following program?

(x % 10 == 0)? [Link](“Divisible by 10”) : [Link](“Not divisible by 10”);

A. ReferenceError
B. Divisible by 10
C. Not divisible by 10
D. None of the above

6. Which JavaScript label catches all the values, except for the ones specified?

A. catch
B. label
C. try
D. default

7. Which are the correct “if” statements to execute certain code if “x” is equal to 2?

A. if(x 2)
B. if(x = 2)
C. if(x == 2)
D. if(x != 2 )

8. What is the output of the following code in the console?

var x = 0;

function fun(){

++x;

this.x = x;

return x;

var bar = new fun();

[Link](bar.x);

A. ReferenceError
B. undefined
C. 1
D. TypeError
9. Which is the correct JavaScript syntax to change the HTML content given below?

<p id=”test”>Hello World!</p>

A. [Link](“test”).innerHTML = “Hello World!”;


B. [Link](“test”).innerHTML = “Hello World!”;
C. [Link](test).innerHTML = “Hello World!”;
D. [Link](“p”)[0].innerHTML = “Hello World!”;

10. Javascript is a _____ language.

A. Programming
B. Application
C. Scripting
D. None of the above

11. Which of the following purpose, JavaScript is designed for ?

A. To Execute Query Related to DB on Server


B. To Style HTML Pages
C. To Perform Server Side Scripting Opertion
D. To add interactivity to HTML Pages.

12. JavaScript code is written inside file having extension

A. .jvs
B. .js
C. .jsc
D. .javascript

13. What are the three important manipulations done in a for loop on a loop variable?

A. Updation, Incrementation, Initialization


B. Initialization,Testing, Updation
C. Testing, Updation, Testing
D. Initialization,Testing, Incrementation

14. What kind of expression is "new Point(2,3)"?

A. Primary Expression
B. Object Creation Expression
C. Invocation Expression
D. Constructor Calling Expression

15. Which event is triggered automatically at certain interval?

A. setTimeout
B. setTimer
C. Timeout
D. interval

Common questions

Powered by AI

In a JavaScript switch statement, 'default' is used as a fallback case that executes if none of the specified cases match the switch expression. It catches all values not specifically handled by a preceding case statement, similar to the 'else' in an if-else structure .

The 'Math.min(x, y)' method returns the smallest of zero or more numbers. It is part of the Math object and is commonly used when you need to determine the lower value between two or more numbers, such as finding the minimum in a set of values to implement logic based on thresholds .

The key difference between 'setInterval' and 'setTimeout' in JavaScript is that 'setInterval' repeatedly triggers an event at specified intervals until it is cleared, whereas 'setTimeout' triggers an event only once after a set delay. 'setInterval' is used for ongoing periodic tasks, like updating a clock display, while 'setTimeout' is suited for delayed actions, like creating a timeout after a user action .

The ternary operator '? :' in JavaScript is a shorthand for an if-else statement. In the expression '(x % 10 == 0) ? console.log("Divisible by 10") : console.log("Not divisible by 10");', it evaluates whether 'x % 10 == 0' is true. If true, it executes the first expression 'console.log("Divisible by 10")'; otherwise, it executes the second 'console.log("Not divisible by 10")'. It is useful for concise conditional expressions .

The result of the expression '3 > 2 > 1 === false' is true. The expression is evaluated from left to right, so '3 > 2' is evaluated first, returning true. In JavaScript, true is treated as 1 when compared with numbers, so '1 > 1' returns false. Thus, 'false === false' returns true as both sides are equal .

JavaScript is used as a client-side language for creating interactive web pages by manipulating the Document Object Model (DOM). It can perform tasks such as form validation, content updates, and asynchronous requests (AJAX). As a server-side language, notably with Node.js, it can handle HTTP requests, perform database operations, and serve dynamic content .

In JavaScript, 'new' is followed by a function invocation to create a new instance of an object. The function serves as a constructor. For example, 'new Point(2,3)' creates a new object with its type defined by the function 'Point'. Inside 'Point', 'this' refers to the new object. This pattern is crucial for implementing custom object types and ensuring each instance has its own properties .

JavaScript is distinguished as a 'scripting language' because it is primarily used to automate tasks and enhance interactivity within web applications, rather than for standalone software development. Unlike compiled languages, JavaScript is interpreted at runtime, which allows for dynamic execution of code within web browsers without the need for recompilation .

The method 'alert("Hello World!")' is correct for displaying a message in an alert box because 'alert' is a built-in function in JavaScript that creates a modal dialog with the specified message. Alternatives such as 'alertBox("Hello World!")' or 'msgAlert("Hello World!")' are incorrect since they are not part of JavaScript’s global methods .

In this scenario, 'var bar = new fun();' creates an instance of the function 'fun'. Inside 'fun', '++x;' increments the global variable x, and 'this.x = x;' assigns the incremented value of x (which is 1) to the property 'x' of the new object 'bar'. Therefore, 'console.log(bar.x);' outputs 1 because it accesses the 'x' property of the 'bar' object .

You might also like