Javascript Essentials | Fresco Play

Javascript Essentials | Fresco Play

Monday, May 22, 2023
~ 6 min read
Javascript Essentials | Fresco Play

Question 1: What option would you specify when inserting code in a web page?

Answer: script type="____" - text/JavaScript


Question 2: Is the following a valid variable definition? var 100apples

Answer: No


Question 3: Is the following a valid variable assignment var product cost = 3.45;

Answer: No. There should be no space in the variable name


Question 4: What is the ideal place to load the external JavaScript file in your HTML document

Answer: Towards the end of the body to increase the performance of the webpage


Question 5: you want to create an alert. Select the correct one

Answer: alert('he said "goodbye" ');


Question 6: To display whether a value is a number or not, ____ is used

Answer: isNan


Question 7: Select the statement that has correct JavaScript syntax

Answer: console.log("text");


Question 8: What is true about variables

Answer: Variables are case sensitive


Question 9: JavaScript has to called inside ________ tags

Answer: script


Question 10: Which of the following are not valid in JavaScript?

Answer: "My name is "Harry" "


Question 11: What is the value of C? var a = 100; var b = "10"; var c = a + b;

Answer: 10010


Question 12: Which statement will return the value false?

Answer: var result = (20 === "20") && (50 < 30);


Question 13: What is the output for code A and B?

Answer: 10,11


Question 14: Multiple variables can be created and initialized in a single JavaScript statement

Answer: True


Question 15: ____ allows you to loop through a block of code as long as the specified condition is true.

Answer: While


Question 16: ____ is used to exit a loop early.

Answer: Break


Question 17: __ is a pretest loop that will execute until the value of z equals 10

Answer: while (z >10) { z--; }


Question 18: In multidimensional array mySubject, which of the following will allow assigning the value 100 in position 5 of the third mySubject array?

Answer: mySubject[2][4] = 100


Question 19: In JavaScript, object is a container of properties and functions. Properties are identified by ____ and behavior is identified by _____

Answer: variables, functions


Question 20: What is true about array

Answer: Can have combination of data types in a single array list


Question 21: To retrieve the day of the month from the Date object, which is the code to select?

Answer: var month_day = date_obj.getDate();


Question 22: var date_obj = new Date(2016,1,1);

Answer: var month_day = date_obj.getDate();


Question 23: Which is the correct way to create an array in JavaScript? I) var myProg = []; II) var myArray = ["C","Java","C++","Python"]; III) var myProg = new Array();

Answer: I, II & III


Question 24: Can arrays in JavaScript be extended?

Answer: Yes, They can be


Question 25: Which of the following regarding scope is true?

Answer: Variables that have a local scope are only visible in the function in which they are declared


Question 26: Object's properties are similar to variables and methods are similar to

Answer: Functions


Question 27: What is true about functions : I) Functions are objects II) Can be assigned to a variable III) Can be anonymous IV) Return value type has to be defined in function declaration

Answer: I, II, III


Question 28: Anonymous functions can be created in JavaScript. What do anonymous function do?

Answer: Process a variable before passing it on to another function


Question 29: _____ is an function contained within an object

Answer: Method


Question 30: function multi(a,b) { var ans = a * b; return ans; } var c = _________ multi(15,2);

Answer: multi();


Question 31: Function in JavaScript is an object. True or False ?

Answer: True


Question 32: Which statement about the name and id attributes of form fields is false?

Answer: The id attribute is what is sent when the form is submitted.


Question 33: Which statement accesses HTML classes?

Answer: getElementsByClassName


Question 34: Your div element in a document has id="answers". If a JS fn sets d=document.getElementById("answers"), then which is the preferred way to add a paragraph containing the word "Hello" as a child of that div?

Answer: p = createElement("p"); p.innerHTML = "Hello"; d.appendChild(p);


Question 35: If a JS fn sets d=document.getElementById("answers"), then which is the preferred way to add a paragraph containing the word "Hello" as a child of that div?

Answer: p = createElement("p"); p.innerHTML = "Hello"; d.appendChild(p);


Question 36: Document object is part of ____ object

Answer: Window


Question 37: By modifying the DOM, the contents on the page also gets modified

Answer: True


Question 38: For any structured document, _____ defines a standard set of objects

Answer: Core DOM


Question 39: Using HTML button tag, JavaScript command can be executed by using ____ function

Answer: "alert('Button1');"


Question 40: Which is the most preferred way of handling events?

Answer: Register a listener to an element


Question 41: How many 'onload' events can be written in a page

Answer: True


Question 42: _ object is used to make calls and request data from server

Answer: XMLHttpRequest


Question 43: AJAX requests can support data transfer in ______ format

Answer: Any


Question 44: The data from the AJAX request is usually in XML. True or False?

Answer: False


Question 45: isNan function returns ______ if the argument is not a number otherwise it is ______

Answer: True / False


Question 46: To modify a group of elements in the page, _______ can be used

Answer: getElementsbyTagName


Question 47: What is the output you get for the following code? (function() { return typeof arguments; }) ();

Answer: object


Question 48: What is the output for the following code (function f(){ function f(){ return 1; } return f(); function f(){ return 2; } })();

Answer: 2


Question 49: var i = 1; if (function f(){}) { i += typeof f; } x;

Answer: True


Post a comment

Comments

Join the conversation and share your thoughts! Leave the first comment.

Get your FREE PDF on "100 Ways to Try ChatGPT Today"

Generating link, please wait for: 60 seconds

Checkout all hot deals now 🔥

Search blogs

No blog posts found