Quiz
JavaScript Review Part 1
This quiz has question types that open in the usual player.
Questions in this quiz (200)
1Arrow functions don’t require parentheses when the function has ____.
- AOne parameter
- BTwo arguments
- CZero arguments
- DAll of the answers
2Given a function that has two default parameters. You want to keep the default value of the first parameter but override the default value of the second parameter. When calling the function, what value should the first parameter be?
- ANull
- BUndefined
- C0
- Dfalse
3Which of the following functions correctly implements default parameters?
- AFunction myFunction(name: 'Ken') { … }
- BFunction myFunction(name = 'Ken') { ... }
- CFunction myFunction() { let name = args[0] || 'Ken'; … }
- DAny of these.
4An arrow function is bound to its _____ scope.
- ASister
- BChild
- CParent
- DPrevious
5Default values can only be strings.
- AFalse. The values can be strings, booleans, objects, arrays, or functions.
- BTrue. If you pass a value that's not a string, the interpreter will throw an exception.
6Which of the following is using a spread operator?
- Alet [toy1, toy2, toy3] = toys;
- Bfunction makeToy(type, ...options) { … }
- Clet toys = [...cars, ...trucks, ...dolls, ...blocks];
- DAll of These
7Which of the following is using a rest parameter?
- Alet cars = [...honda, ...toyota, ...chevrolet];
- Bfunction buildCar(make, model, ...options) { … }
- Clet {hood, transmission, engine} = car;
- DAll of these
8You can use the spread operator and destructuring together.
- ATrue
- BFalse
9_______ is a way to reference object or array values with variables.
- ARest Parameters
- BObject Composition
- CPromises
- DDestructuring
10The spread operator can be used instead of _____.
- AArray.concat
- BArray.split
- CArray.forEach
- DObject.create
11Object Property Shorthand can be used with which of the following value types?
- ABooleans
- BNumbers
- CStrings
- DClasses
- EAll of these
12You can terminate (break) a for...of loop before it reaches the end of an iterable.
- ATrue
- BFalse
13for...of syntax can be used with which of the following value types?
- AString
- BArray
- CMap
- DSet
- EAll of these
14When the interpreter encounters a variable assignment without a property key, the _______ is used as the property key.
- AMethod
- BValue
- CConstant
- DVariable Name
15for...of can loop over regular Objects.
- ATrue
- BFalse
16To retrieve a value for a given key from a Map, you would use which method?
- Aget
- Bmatch
- Chas
- Dfind
17To empty a Set or Map object of all stored values, you use which method?
- Aempty
- Bdelete
- Ctruncate
- Dclear
18The method to add a value to a Map is _____.
- Aadd
- Binsert
- Cimport
- Dset
19To create an array from a Set object use ____.
- AArray.concat
- BArray.from
- CArray.push
- DArray.fromSet
20A Set is an iterable object that holds _______.
- Aunique values
- Bobject definitions
- Ca collection of arrays
- Dstring literal values
21The code in the _______ block is executed when the class is called with the 'new' keyword.
- Aconstructor
- Bget
- Cclass
- Dstatic
22When referencing a class, the class must be defined before it can be used. Named functions are ______, while classes are not.
- Ahoisted
- Bpersistent
- Cnative
- Dstatic
23When extending a class you must be sure to call the _______ in the child class constructor before any reference to the instance.
- Anew keyword
- Bsuper() function
- Cbreak
- Dcreate() function
24Destructuring is one way to set ______ values for class properties.
- Adefault
- Bstring
- Cstatic
- Dconstant
25A sub-class can override methods and properties of a parent class.
- ATrue
- BFalse
26A getter is a function that has no ________ and must return a value.
- Acontext
- Bparent
- Cvariables
- Dparameters
27A static function is prefixed with the ______ keyword.
- Asuper
- Bstatic
- Cprivate
- Dpublic
28A setter is a function that has one _________ which is the value on the right side of an equals sign.
- Aparameter
- Bvariable
- Cconstant
- Dsub-class
29You can access a static method through an instance of a class.
- ATrue
- BFalse
30A static method is one that exists on the class declaration and not on each ______.
- Amethod
- Binstance
- Cchild class
- Dvariable
31The ____ method let's you check a string for a set of matching characters.
- Afind
- Bmatches
- Cincludes
- Dexists
32let and const type variables can be accessed from ______.
- Aparent scopes
- Bthe global scope
- Ceverywhere
- Dnested scopes
33Which of the following is not a method for searching a string?
- Ahas
- BendsWith
- Cincludes
- DstartsWith
34Which of the following will log "My Favorite Number is 10!"?
- Aconsole.log('My Favorite Number is ' + 4 + 6 + '!');
- Bconsole.log(`My Favorite Number is ${4 + 6}!`);
- Cconsole.log(`My Favorite Number is {4 + 6}!`);
- Dconsole.log('My Favorite Number is #[4+6]!');
35let and const are best used for ______.
- Acomposing objects
- Bfunction parameters
- Cblock-level scoping
- Dtemplate strings
36Finish the code below to insert the contents of the variable "sidebarHTML" into an HTML element with the ID of "sidebar". Make sure you insert this content as HTML using jQuery.
$('#sidebar'). [blank_start]html(sidebarHTML)[blank_end];- Ahtml(sidebarHTML)
37Assume you have the following JavaScript object:
var contact = {
name : "Jill",
phone: "510-555-1212"
};
Finish the code below to display the object's "name" property in an alert box:
alert([blank_start]contact.name[blank_end]);- Acontact.name
38You can use jQuery's $.each() function to process an array of items. What two arguments are passed to the callback function that processes the array?
- A1. A jQuery selection
2. Another callback function - B1. An object
2. The array - C1. The value of the current array item
2. A jQuery Event object - D1. The index value of the current array item
2. The value of the current array item - E1. The array
2. An anonymous callback function
- A1. A jQuery selection
39jQuery's $.each() method is a faster way to write what type of JavaScript structure?
- AAn array
- BA regular expression
- CA loop
- DAn if/else statement
- EA switch statement
40What two parameters does jQuery's $.each() method accept?
- A1. An object
2. A callback to process the object's property names and values - B1. An array
2. A callback function to process the array items - C1. A jQuery selection of page elements
2. A callback function to access each page element
- A1. An object
41You can send Flickr's public photo feed a property named "tags". What does the "tags" property do?
- AIt lets you tag photos with different keywords.
- BIt lets you tag other photographers on Flickr to add their photos to your photo feed.
- CIt lets you search for photos that match a particular keyword.
- DIt lets you specify the format you want to receive the Flickr feed in.
- ENone of the above.
42Finish the code below to retrieve the text inside an HTML element with the ID of "button" and store it in the variable "animal":
var animal = $('#button').[blank_start]text()[blank_end];- Atext()
43Which of jQuery's AJAX methods can you use to make a JSONP request?
- A$.getJSONP()
- B$.post()
- C$.load()
- D$.get()
- E$.getJSON()
44You can send Flickr's public photo feed a property named "format". What does the "format" property do?
- AIt lets you convert string formatted data into pure JavaScript.
- BIt lets you specify the format for the feed, for example an XML or JSON format.
- CIt lets you format photographs in either landscape or portrait mode.
- DIt doesn't do anything. This is no longer a valid option for Flickr's public photo feed.
- EIt lets you specify a size for the photographs Flickr sends.
45What 3 parameters does jQuery's $.getJSON() method accept?
- A1. A URL
2. An XML document containing data
3. A callback function to pre-process data sent to the server - B1. A URL
2. A JavaScript object to send data to the server
3. A callback function to process the response from the server - C1. A callback function to process the response from the server
2. A jQuery Selector
3. Data to send to the server - DNone of the above. jQuery's $.getJSON() method only accepts two arguments.
- A1. A URL
46Complete the code below to remove the class "selected" from all button elements.
$("button").[blank_start]removeClass[blank_end]("selected");- AremoveClass
47Fill in the missing code to add a click event handler to all HTML button elements on a page:
$([blank_start]"button"[blank_end]).click(function() {
});- A"button"
48What is the name for this type of function:
function () {
}- AA named function
- BAn anonymous function
- CA function declaration
- DThis is an invalid way to format a function
- EA hoisted function
49What does this code do?
$(document).ready(function () {
});- AIt writes messages to the document.
- BIt doesn't do anything -- it's invalid JavaScript and jQuery code.
- CIt's needed to add event handlers with jQuery.
- DIt waits until the HTML for the page has loaded before running the JavaScript code placed inside it.
- EIt makes the document ready to run jQuery. You can't use jQuery without it.
50What is JSONP?
- AA method for requesting data from another web server by bypassing a web browser's "same origin" policy.
- BJSON with Padding.
- CA way of sending data in a JavaScript file.
- DAll of these.
- ENone of these.
51What is an API key for?
- ALets a web developer connect with a third party API like Google Maps.
- BLets a web site limit access to its API.
- CLets a web site track use of its API and charge money for its use.
- DAll of the these.
52Finish this code to retrieve a JSON formatted version of the Flickr Public Photo Feed:
https://api.flickr.com/services/feeds/photos_public.gne[blank_start]?format=json[blank_end]- A?format=json
53Which of the following programming languages can be used to talk to third-party APIs?
- ARuby
- BPHP
- CPython
- DJavaScript
- EAll of these.
54What does API stand for?
- AAsynchronous Polling Interface
- BAsynchronous Programming Interface
- CAutomated Processing Interface
- DAdvanced Programming Integration
- EApplication Programming Interface
55An API lets you connect to a third-party web site like YouTube or Twitter and request content.
- ATrue
- BFalse
56What is the jQuery method for handling errors in an AJAX response?
- A.fail()
- B.response()
- C.error()
- D.badResponse()
- E.status()
57In which of the following situations does jQuery's .fail() method NOT work?
- AWhen using the $.get() method.
- BWhen using the .load() method.
- CWhen making requests to another site.
58The callback function for jQuery's .fail() method receives a jQuery XHR object as a parameter. What property of the jQuery XHR object provides the response's HTTP status code?
- AresponseCode
- BstatusText
- CstatusCode
- Dstatus
59The callback function for jQuery's .fail() method receives a jQuery XHR object as a parameter. What property of the jQuery XHR object provides a text description of the response's status code?
- AresponseText
- BstatusText
- Cstatus
- DstatusResponse
- Eresponse
60What is jQuery's low-level AJAX method -- the one all the shorthand methods are built on?
- A$.ajax()
- B.ajax()
- C$.AJAX()
- D.AJAX()
61Which of the following correctly shows the $.ajax() method in action?
- A$('#sidebar').ajax("sidebar.html", function (response) {
$('#sidebar').html(response);
}); - B$.ajax("sidebar.html", function(response) {
$(this).html(response);
}); - C$.ajax("sidebar.html", {
success : function(response) {
$('#sidebar').html(response);
}
}); - D$.ajax(function(response) {
$('#sidebar').html(response);
});
- A$('#sidebar').ajax("sidebar.html", function (response) {
62jQuery's $.ajax() method accepts a JavaScript object containing settings for how the AJAX request is handled. What is that object's success property used for?
- ATo print a success message on the page.
- BTo set a success message sent to the callback function that handles the web server's response.
- CTo send a success message to the web server.
- DTo set the status text of the AJAX request.
- ETo set a callback function that runs when the browser successfully receives a response from the server.
63Why would you use jQuery's $.ajax() method instead of one of the simpler shorthand methods like $.get(), $.getJSON() or $.post()?
- AThe $.ajax() method has more options and provides greater control of the AJAX request.
- BThe $.ajax() method lets you set a timeout to control how long you're willing to wait for a response from a server.
- CThe $.ajax() method lets you send a username and password to resources that require user authentication.
- DAll of these.
64What two parameters does jQuery's $.ajax() method accept?
- A1. A URL
2. A callback function that runs when the server returns a response - B1. A URL
2. A JavaScript object containing settings that control how the AJAX request is made - C1. A URL
2. Data to send to the server - D1. Data
2. A callback function that runs when the server returns a response
- A1. A URL
65Which of the following jQuery AJAX shorthand methods posts data to a server?
- A$.ajaxPost()
- B$.POST()
- C$.post()
- D.ajaxPost()
- E.post()
66What does jQuery's preventDefault() method do?
- AStops a browser from applying its default styling to HTML elements.
- BPrevents a visitor from changing the default value of a text field in an HTML form.
- CIt ends an event handler's callback function and returns to the main part of a JavaScript program.
- DIt's used with an event object to prevent the browser from responding normally to an event -- for example, it prevents a form from being submitted, or loading a new web page when a link is clicked.
67Complete the code below to add a submit event handler to a form:
$('form').__(function (evt) {
});- Asubmit
- Bready
- Cajax
- Dpost
68Complete this code to retrieve a form's "action" attribute and store it in the variable url:
var url = $('form').__("action");- Aclass
- Bajax
- Cattr
69What does jQuery's serialize() method do?
- ACreates a text string out of an array or JavaScript object for use in a URL or as part of an AJAX request.
- BCreates a text string with standard URL-encoded notation of fields in an HTML form.
- CGets the value of an attribute for an HTML element in a jQuery selection.
- DTakes a selection of multiple HTML elements and concatenates their text values into a single text string.
- ENone of these.
70What is the difference between jQuery's .load() AJAX method and jQuery's other shorthand AJAX methods?
- AThe .load() method is the ONLY way to load a JavaScript file using jQuery.
- BThe .load() method is the ONLY method that accepts a callback function to handle AJAX errors.
- CThe .load() method is the ONLY way to load HTML content via AJAX.
- DThe .load() method must be chained onto a jQuery selection. For example, $('#element').load('page.html');
71jQuery's $.get() method accepts three arguments. What order do they go in?
- A1. Callback function to process the server response
2. URL
3. Data for the server - B1. URL
2. Callback function to process the server response
3. Data for the server - C1. Data for the server
2. Callback function to process the server response
3. URL - D1. URL
2. Data for the server
3. Callback function to process the server response - E1. Callback function to process the server response
2. Data for the server
3. URL
- A1. Callback function to process the server response
72Which of the following is NOT a jQuery AJAX shorthand method?
- A.load()
- B$.get()
- C$.post()
- D$.getJSON()
- EAll of these are shorthand AJAX methods
73jQuery passes the data from the server response to the callback function of $.get(). This is the same as which of the following XMLHTTPRequest object properties?
- AThe status property
- BThe readyState property
- CThe statusText property
- DThe responseText property
74What does CDN stand for?
- AContent Delivery Network
- BCross Domain Networking
- CComputer Developer Network
- DCrafted Data Normalization
75What does this code do:
$('#ajax').load('sidebar.html');- AIt doesn't do anything -- this is invalid JavaScript code.
- BIt refreshes the browser and loads a new page named sidebar.html
- CIt updates the contents of the sidebar.html file with the contents of an HTML element with the ID of "ajax."
- DIt loads the contents of the sidebar.html file into an HTML element with the ID of "ajax."
76What is jQuery?
- AA programming language that replaces JavaScript.
- BA JavaScript tool for sending database queries.
- CA popular JavaScript library that simplifies making AJAX requests.
- DA server side component used to process AJAX requests from web browser.
- EAll of these.
77When a web server sends JSON-formatted data, what is it sending?
- Aan array of items
- Ba string
- Ca binary large object
- Da group of objects
78Which of the following is a web browser's method for turning a JSON string into a JavaScript object?
- AparseJSON()
- BJSONParse()
- Cjson.parse()
- Dparse.JSON()
- EJSON.parse()
79What will appear in the alert dialog box when this code runs?
var word = "Treehouse";
alert( typeof word);- Astring
- Bword
- CTreeehouse
- D[Object][Object]
- Enoun
80JSON stands for JavaScript Object Notation.
- ATrue
- BFalse
81Which of the following is true about JSON properties?
- AProperty names must be capitalized
- BProperty names must start with op_
- CProperty names are separated from property values by a comma
- DProperty names must be quoted using double quotes
- ENone of these.
82Which one of the following shows a correctly formatted JSON property name / value pair?
- Acourse : 'AJAX Basics'
- B"course" :: "AJAX Basics"
- C"course" : "AJAX Basics"
- D'course' : 'AJAX Basics'
83Which of the following is valid JSON?
- A[
"AJAX Basics",
"jQuery Basics"
] - B{
"course1" : "AJAX Basics",
"course2" : "jQuery Basics"
} - C"AJAX Basics"
- D[
{
"course" : "AJAX Basics"
},
{
"course" : "jQuery Basics"
}
]
- A[
84JSON data can be formatted in which of these ways?
- AAs an array of values
- BAs a JavaScript object containing property name / value pairs
- CAs an array of JavaScript objects
- DAll of these.
- ENone of these.
85Which of the following correctly creates an XHR object?
- Avar xhr;
- Bvar request = new XMLHttpRequest();
- Cvar xhr = new XMLHttpRequestObject();
- Dvar xhr = XMLHttpRequest();
- Evar request = new xhrObject();
86A variable named xhr contains an XMLHttpRequest Object. Which of these sends the AJAX request to the server?
- Axhr();
- Bxhr.post();
- Cxhr.XMLHttpRequest().send();
- Dxhr.sendRequest();
- Exhr.send();
87What does an HTTP status code of 404 mean?
- AOK
- BAccess Denied
- CInternal Server Error
- DFile Not Found
88What does an HTTP status code of 200 mean?
- AAccess denied
- BOK
- CInternal server error
- DFile not found
89What is the value of an XMLHttpRequest object's readyState when the browser has received all of the data from the server?
- A2
- B3
- C1
- D4
- E5
90What is a common reason for using the GET HTTP Method to send an AJAX request?
- AWhen your web browser doesn't support the POST method.
- BWhen you need to send less than 2083 characters to a web server.
- CWhen you're only interested in getting information from a web server.
- DAll of these.
- ENone of these.
91Which of these is a difference between GET and POST?
- AGET is most often used to send data to be stored in a database. POST is not.
- BThe GET method sends a single request in the URL. The POST method sends two requests: a URL request, and a data request.
- CPOST sends its data in the "body" of the request. GET sends data in the URL.
- DPOST is only for sending data to a web server. You don't send data with GET requests.
- EPOST is limited to 2083 characters in some browsers. GET lets you send unlimited data to a web server in every browser.
92Which of these is an example of a valid query string?
- Ahttp://server.com/page.php
- Bhttp://server.com/page.php?name=Johnny+Depp&movie=Pirates+of+the+Caribbean%3A+Dead+Man%27s+Chest
- Chttp://server.com/page.php?name=Johnny Depp&movie=Pirates of the Caribbean: A Dead Man's Chest
- Dhttp://server.com/name=Johnny Depp&movie=Pirates of the Caribbean: A Dead Man's Chest
93What is a query string?
- AA string used for creating SQL database queries.
- BInformation sent to the web server. It is added to the end of a URL.
- CA JavaScript variable holding a string value. Used to send requests to a search engine.
- DData sent when you make an AJAX request using the POST HTTP method.
94When should you use the POST HTTP method with AJAX?
- AEverytime you submit information from a form.
- BWhen you want to send data that the web server should store in a database.
- CWhen you want to send more than 2083 characters of data to the web server.
95What is one characteristic of "asynchronous" AJAX requests?
- AYour web browser cannot perform any tasks until the server sends back a response.
- BJavaScript programs wait for the server response before continuing.
- CIf you send multiple AJAX requests, the server sends responses in the order the requests were sent.
- DCallbacks for multiple AJAX requests may not run in the order the requests were sent.
- ENone of the above
96What type of JavaScript object do web browsers use to manage AJAX requests?
- AJSON Data Object
- BBrowserRequest Obejct
- CXMLHttpRequest Object
- DAJAX Object
- EXML Response Object
97What are the 4 steps of an AJAX request?
- A1. Write server-side code to process AJAX request
2. Receive AJAX request
3. Process request
4. Send response - B1. Create XMLHttpRequest Object
2. Create callback function
3. Open request
4. Send request - C1. Create XMLHttpRequest Object
2. Create server-side response object
3. Send request
4. Send response - D1. Open connection to server
2. Send data to server
3. Retrieve response from server
4. Process response
- A1. Write server-side code to process AJAX request
98The term "XMLHttpRequest object" is often shortened to which of the following?
- ANone of these.
- BAJAX Object
- CXMLR Object
- DXHRO
- EXHR Object
99AJAX is the W3C's (World Wide Web Consortium's) official term for an XMLHttpRequest.
- ATrue
- BFalse
100AJAX is an acronym for what words?
- AAsymptotic Java Xnodes
- BAngular with JavaScript Xpressions
- CAsynchronous JavaScript And XML
- DAmazon Java XML
- ENone of these.
101What does AJAX let you do?
- ALet's a user navigate to another page on the site.
- BUpdate content on a web page without loading a new web page.
- CSave data to localstorage.
- DAll of these.
102Which server-side languages does AJAX work with?
- ARuby
- BPHP
- CPython
- DCold Fusion
- EAll of these.
103When a server answers an AJAX request it sends back a...
- Arequest
- Bform
- Cresponse
- D404 error
- Epayload
104You use AJAX to communicate with a web server by sending it a ...
- Axhr object
- Bpayload
- Cplea
- Drequest
- Eresponse
105A "Number" is an object that is available in both the Web Browser and in Node.js. This is an example of what kind of object?
- AHost Object
- BNative Object
106If I had the key of "created at" how would I access the value of that property on an object?
- AblogPost."created at";
- BblogPost["created at"];
- CblogPost("created at");
- DblogPost.createdAt;
107All object property keys are of the type String?
- ATrue
- BFalse
108Given the following code.
function Animal(breed, noise)
{
this.breed = breed;
this.noise = noise;
this.makeNoise = function()
{
console.log(this.noise + ", " + this.noise);
}
}
What is the correct way to create an instance of an Animal?- Avar frog = new animal("Tree Frog", "Ribbit");
- Bvar dog = Animal("Dalmatian", "Woof");
- Cvar cat = new Animal("Siamese", "Meow");
- Dvar mouse = new Mouse("House Mouse", "Squeek");
109Given the following code what is the best way to describe task?
function TaskListItem(description) {
this.description = description;
this.isDone = false;
}
TaskListItem.prototype.complete = function() {
this.isDone = true;
}
var task = new TaskListItem("Do the laundry!");- AIt's an instance of a Task.
- BIt's a constructor function.
- CIt's an instance of a TaskListItem.
- DIt's an instance of a TodoListItem.
110function Player() {
this.health = 100;
}
Player.[blank_start]prototype[blank_end].pickUpHealth = function() {
this.health++;
}- Aprototype
111Given the following code:
function Animal(breed, noise) {
this.breed = breed;
this.noise = noise;
}
Animal.prototype.makeNoise = function() {
console.log(this.noise + ", " + this.noise);
}
var frog = new Animal("Tree frog", "Ribbit");
How would I get the frog to "Ribbit, Ribbit"?- AAnimal.makeNoise();
- Bfrog.this.makeNoise();
- Cfrog.makeNoise();
- Dfrog.prototype.makeNoise();
112What argument is missing?
function Shape(sides) {
this.sides = sides;
}
function Square() {
Shape.call([blank_start]this[blank_end], 4);
}
Square.prototype = Object.create(Shape.prototype);- Athis
113The technique used in JavaScript to share functionality between similar types of objects is known as [blank_start]prototypal[blank_end] Inheritance.
- Aprototypal
114This code uses the square bracket syntax to define a method on a prototype of a Contact.
function Contact(fn, ln) {
this.firstName = fn;
this.lastName = ln;
}
Contact.prototype["full name"] = function() {
return this.firstName + " " + this.lastName;
}
var contact = new Contact("Andrew", "Chalkley");
How would I call the "full name" method?- Acontact["full name"]();
- Bcontact.fullName();
- Ccontact["full name"]
115The technique used in JavaScript to share functionality between similar types of objects is known as:
- AProto Inheritance
- BObjectionable Inheritance
- CClassical Inheritance
- DPrototypal Inheritance
116There's a line missing setting up the prototype chain. What does it look like?
function Book(title, author) {
this.title = title;
this.author = author;
}
function Ebook(title, author, fileSize) {
Book.call(this, title, author);
this.fileSize = fileSize;
}- AObject.create(Book.prototype) = Ebook.prototype;
- BEbook.prototype = Object.create(Book.prototype);
- CEbook.prototype = Book.prototype;
117Which sentence best describes the first argument passed in to the call() method?
- AThe first argument sets the value of this when the function is executed.
- BThe first argument is the constructor function.
118The [blank_start]prototype[blank_end] property allows you to add properties and methods to objects with the same constructor function.
- Aprototype
119Given the following code what is the best way to describe Monster?
function Monster(rank) {
this.rank = rank;
this.health = 100;
this.takeHit = function() {
this.health--;
}
this.isDead = function() {
return this.health <= 0;
}
}
var monster = new Monster("Captain");- AIt's a regular function.
- BIt's an instance of Monster.
- CIt's a constructor function.
120Given the following code.
function Animal(breed, noise) {
this.breed = breed;
this.noise = noise;
this.makeNoise = function() {
console.log(this.noise + ", " + this.noise);
}
}
What is the correct way to create an instance of an Animal?- Avar horse = new Animal("Shetland pony", "Neigh");
- Bvar frog = new animal("Tree Frog", "Ribbit");
- Cvar dog = Animal("Dalmatian", "Woof");
- Dvar cat = new Cat("Siamese", "Meow");
121Given the following code what is the best way to describe task?
function TodoListItem(description) {
this.description = description;
this.isDone = false;
this.toString = function() {
return this.description;
}
this.markAsComplete = function() {
this.isDone = true;
}
}
var task = new TodoListItem("Do the laundry!");- AIt's a constructor function.
- BIt's an instance of a TodoListItem.
- CIt's a string of "Do the laundry!"
122Which of these is NOT a valid way to access a property, "name", on an object?
- Acat.name;
- Bcat["name"];
- Cvar key = "name"; cat[key];
- Dvar key = "name"; cat.key;
123All object property keys are of the type String?
- ATrue
- BFalse
124Functionality encapsulated by an object is known as a [blank_start]method[blank_end].
- Amethod
125Values stored in objects are called [blank_start]properties[blank_end].
- Aproperties
126An "Array" is an object that is available in both the Web Browser and in Node.js. This is an example of what kind of object?
- AHost Object
- BNative Object
127The "document" is only available in the Web Browser. What kind of object is this?
- AHost Object
- BNative Object
128When you're talking about an object's "state" what are you referring to?
- AThe condition of all values at a particular point in time.
- BWhere the object was created.
- CThe behaviors of the object.
129A "String" is what kind of object in JavaScript?
- ANative Object
- BHost Object
130What event triggers when all of the DOM has been parsed and loaded into the browser?
This event signals that it's safe to select elements, manipulate them, or set listeners on them.- Aloadend
- BDOMContentLoaded
- CDOMLoaded
- Dsubmit
131The process of rewriting code while leaving the original behavior exactly the same is called:
- ADRY
- BDefensive programming
- CRefactoring
132Why are JavaScript functions known as first-class citizens?
- AFunctions bubble up through the DOM tree.
- BFunctions can be passed into other functions, assigned to variables, even be stored in arrays and objects.
- CYou are not able to create functions that can accept functions as well as return functions.
133Given this code:
function createElement(elementName, property, value) {
const element = document.createElement(elementName);
element[property] = value;
}
What is the purpose of the bracket syntax?- AThe brackets require property to always be a valid JavaScript identifier.
- BThe brackets will throw an error.
- CThe brackets dynamically access the value using the string contained in value.
- DThe brackets dynamically access the property of element using the string contained in property.
134When refactoring a program, a good place to start is to:
- Aidentify and remove duplicate code
- Bcreate a function for everything
- Ccopy and paste code for all similar actions
135If you need to store telephone numbers in an array, what would generally be the best variable name to use for the array?
- Atns
- BtelephoneNumbers
- Cstuff
- Darray
136const card = document.querySelector('.card');
const footer = document.querySelector('footer');
const div = document.createElement('div');
...
card.insertBefore(div, footer);
Given the code above, the insertBefore method will:- Ainsert a div before a footer element as a child of .card
- Binsert a footer before a div element as a child of .card
- Cinsert div and footer elements as a children of .card
137Given the following code:
card.addEventListener('click', (e) => {
if (e.target.tagName === 'BUTTON') {
if (e.target.textContent === 'remove') {
console.log("I'm being removed");
}
}
});
The console will output the message "I'm being removed":- Aif the clicked element's text content is "I'm being removed"
- Bif the clicked element is a button AND if its class is "remove"
- Cif the clicked element is a button AND if its text content is "remove"
- Donly if the clicked element is a button
138Given this code:
const article = document.querySelector('.article');
const headline = article.firstElementChild;
What does headline return?- AThe parent element of article
- BA collection of the child elements of article
- COnly the first child element of article
139Text elements are accessed and manipulated differently than HTML elements.
To simplify the way you manipulate a text element, you can turn it into an HTML element.- ATrue
- BFalse
140Given the following code:
const names = document.getElementById('names');
const nameList = names.children;
What will nameList return?- AA collection of all the child elements of names
- Bundefined
- CA collection of all the ancestor elements of names
- DOnly the first child element of names
141How does JavaScript function scoping work?
- AVariables declared inside a function are visible from the outside.
- BVariables declared inside a function are visible within all other functions.
- CVariables declared outside a function are visible from the inside.
- DVariables declared in the global scope are only accessible outside all functions.
142You will often need to provide the user with one or more HTML input elements when your application is in an "editing state".
- ATrue
- BFalse
143What is the event object?
- AA global object that you use to trigger events in your application.
- BA normal JavaScript object that you declare yourself for managing user events.
- CAn object provided to an event handler that contains information about the event.
144When manipulating the DOM to replace one element with another, the text contained in the removed element will automatically move to the new element, and will not need to be handled in the code you write.
- ATrue
- BFalse
145Inside an event handler, how would you find a reference to the element that received the event?
- AThe `element` property on the event object
- BThe `target` property on the event object
- CThe reference is always on the global scope in the `event` property.
- DDeclare a variable named 'eventTarget', and don't assign it a value.
146Which of the following is NOT something you want in a jQuery plugin.
- AOnly supports the latest versions of Chrome and Firefox.
- BHas detailed documentation.
- CWorks in responsive designs.
- DIs mobile friendly.
147What does the CSS z-index property do?
- AThe z-index property lets you control the layering (or stacking) of relative, absolute and fixed position elements.
- BIt's used to create 3D Transforms for advanced animation techniques.
- CThe z-index property controls how search engines index your page elements, giving more weight to some content than other.
- DThe z-index property lets you control the layering (or stacking) of any page element on top of another.
148Assume that you have a series of div tags inside this div:<div id="slideContainer">
Complete this code to select that div and apply the slick plugin:
$('[blank_start]#slideContainer[blank_end]').slick();- A#slideContainer
149Plugins often add class names to HTML dynamically (meaning after the page loads, and while a visitor interacts with it.) Why is this useful?
- ASo that the HTML the plugin adds to the page doesn't interfere with styles already in place.
- BSo that you can create custom CSS styles to format the appearance of the plugin on the page.
- CSo that the plugin author can create a style sheet to control the look of the plugin.
150What is a custom plugin event?
A custom event is something that "happens," but it's not a normal browser event. It's something the plugin does -- like sticking a nav bar to the top of the browser window. You can write custom programming to do something when that happens.- A"Hooks" added by a plugin author to let you write programming to respond to things the plugin does.
- BThere is no such thing.
- ConClick
onMouseover
onMouseOff - DProgramming you add to a plugin so that it can respond to normal browser events like click and mouseover.
151jQuery plugins often include which of the following types of files?
- ACSS
- BJavaScript
- CImages
- DAll of these.
152Why is it a good idea to keep a plugin's CSS, image and JavaScript files together in a single folder for that plugin?
- APlugins require that their files remain in a strict folder structure. Otherwise, links between the files won't work.
- BIf you split the files into different folders on your site, it will be more difficult to update the plugin when it changes or remove it if you no longer want it.
- CIt's not a good idea at all. Don't do it.
153What is the most common way to pass settings that control a jQuery plugin?
- AAn array.
- BA simple variable.
- CA jQuery selection.
- DAn object literal.
154jQuery Plugins no longer need jQuery, since JavaScript now works the same in all current browsers.
- ATrue
- BFalse
155Which of these code snippets shows the correct order in which to attach a plugin file and jQuery to a web page?
- A<script src="js/the_plugin/plugin.min.js"></script>
<script src="js/jquery.min.js"></script> - B<script src="js/jquery.min.js"></script>
<script src="js/the_plugin/plugin.min.js"></script>
- A<script src="js/the_plugin/plugin.min.js"></script>
156What are jQuery Plugins most often used for?
- AFor making jQuery work with older browsers and mobile devices.
- BTo manage routing paths for complex web apps.
- CTo connect front-end forms with back-end database systems.
- DTo add interactive user interface elements to web pages like sliders, carousels and lightboxes.
157We can select the parent of a particular element using CSS only.
- ATrue
- BFalse
158What jQuery method could you use to select all of a particular element’s ancestors?
- Aparent()
- Bparents()
- Cfind()
- Dancestors()
159In order to select an ancestor of the matched element(s), we can use the _______ method or the _______ method.
- Afind(), parent()
- Bsibling(), find()
- Cparent(), closest()
- Dprev(), next()
160The map() method creates a new jQuery object.
- ATrue
- BFalse
161Using the sibling() method will result in a set of elements that includes the original matched element(s).
- ATrue
- BFalse
162Node A contains Node B and is exactly one level up within the DOM tree. Node A is a/an _______ of Node B.
- ASibling
- BDescendant
- CAncestor
- DParent
- EChild
163DOM traversal involves…
- AMoving nodes around to different places in the DOM
- BMoving from one node or set of nodes to another within the DOM
- CUsing JavaScript for supply chain management
164What does the acronym DRY stand for?
- ADon’t Read YAML
- BDocument, Read, Yield
- CDon't Repeat Yourself
- DDocument Ready Yourself
165The relationships between nodes in the Document Object Model are named for those between…
- AAnimal species
- BNaval Ranks
- CFamily Members
166Node A has the same parent element as Node B and both are on the same level within the DOM tree. Node A is a/an _______ of Node B.
- ASibling
- BAncestor
- CParent
- DChild
- EDescendant
167What is the node at the base of the DOM tree called?
- Aancestor
- Broot
- Cwindow
- Ddocument
168Node A is contained within Node B, one or more levels down within the DOM tree. Node A is a/an _______ of Node B.
- AParent
- BChild
- CDescendant
- DAncestor
- ESibling
169Node A is contained within Node B, exactly one level down within the DOM tree. Node A is a/an _______ of Node B.
- AChild
- BDescendant
- CSibling
- DParent
- EAncestor
170What should be passed to the css() method when using it as a setter?
- AThe property we want to change and the value we want to change it to
- BThe property we want to get the value of
- CThe path to our main CSS file
- DThe CSS selector necessary to select the element we want to affect
171Passing 4000 to the slideIn() method will cause the animation to take:
- A4 seconds
- B4000 seconds
- C4000 minutes
- D4 minutes
172What is the purpose of beginning a variable name with a dollar sign ($)?
- AIt helps us preventing naming collisions
- BThere is no inherent meaning, but we do this with variables holding jQuery objects by convention
- CIt requires us to use jQuery methods on the variable
173A [blank_start]getter[blank_end] is a function that is used to retrieve information whereas a [blank_start]setter[blank_end] is used to assign a value.
- Agetter
- Bsetter
174What method is used as a shorthand for many different event methods in jQuery?
- Aevent()
- Bhandle()
- Ctrigger()
- Don()
175In the Node.js documentation I can use the [blank_start]stability[blank_end] Index to help me decide what APIs I should use.
- Astability
176 Non-Blocking means it can perform other tasks whilst it waits on others to complete.
Node.js is:- ANon-blocking
- BBlocking
177The Array object is what type of object?
Other examples of these objects are `String`, `Number`, `Date` and `Math`.- AHost
- BNative
178What is Node.js' default JavaScript engine?
- ASafari's JavaScriptCore
- BFirefox's SpiderMonkey
- CSamsung's JerryScript
- DChrome's V8
179When I want to write an error message to the terminal what method should I call on the console?
- Aerror
- Blog
- Cdir
- Dinfo
180The File System (fs) API is available in which environment?
- ANode.js
- BThe Browser
181If I had a file named index.js how would I run that in the Node.js environment?
- Anode.js index.js
- Bnode run index.js
- Cnode index.js
- Dnode.js index
182If I type node into the console and hit return what would happen?
- AAn interactive REPL (a read-evaluate-print-loop) would start
- BA stack trace would appear
- CIt would show the current version number of Node.js installed
- DA prompt asking for a filename would appear
183The Stability Index of 0 on the Node.js Documentation means:
- AStable
- BExperimental
- CDeprecated
- DLocked
184How do you exit the Node.js REPL (read-eval-print-loop)?
- APress CTRL+C once
- BPress CTRL+C twice
- CCTRL + ALT + DELETE once
- DCTRL + ALT + DELETE twice
185What is the global object we can access the current version of node and arguments passed in to the command line?
- Aglobal
- Bwindow
- Cprocess
186The command line arguments can be accessed through which property on the `process` object?
- Aargs
- Bargv
- Carguments
187Given the following code what will happen?
https.get("https://wwwteamtreehouse.com/chalkers.json", function(response) {
console.log(response.statusCode);
}).on("error", function(error) {
console.error("Something went wrong with the connection!");
});- AIt'll print out "404" because the URL doesn't exist.
- BIt'll print out "200" because everything is OK.
- CIt'll print out the error "Something went wrong with the connection!".
188What object do you use to access the short descriptions for standard HTTP status codes?
- Ahttp.STATUS_CODES
- Bhttp.status_codes
- Chttp.statusCodes
- Dhttp.StatusCodes
189Given the following code what will happen?
const personString = '{"name": "Lauren"}';
try {
const person = JSON.parse(personString);
console.log(person.name);
} catch(err) {
console.error("Couldn't parse the JSON");
}- AThe name of "Lauren" will be printed out.
- BThe error of "Couldn't parse the JSON" will be printed out.
190Given the following code in `greeting.js`:
function sayGreeting() {
console.log("Hello World");
}
module.exports.say = sayGreeting;
How would you access the functionality from another file?- Aconst greeting = require("./greeting");
greeting.say(); - Bconst greeting = require("./greeting");
greeting.sayGreeting();
- Aconst greeting = require("./greeting");
191If I had a file printer.js and wanted to require it in another JavaScript file in the same directory would this work?
const printer = require("./printer");- AYes
- BNo
192If I had a file stocks.js and wanted to require it in another JavaScript file in the same directory would this work?
const stocks = require("stocks");- ANo
- BYes
193When I do debug some code and log out the contents of an object what should I call on the console to see all properties?
- Aerror
- Bdir
- Cinfo
- Dlog
194Given the following code what will happen?
const personString = 'Person: {"name": "Andrew" }';
try {
const person = JSON.parse(personString);
console.log(person.name);
} catch(err) {
console.error("Couldn't parse the JSON");
}- AAndrew will be printed out.
- BCouldn't parse the JSON will be printed out
195Given the following code in `dog.js`:
function bark() {
console.log("Woof!");
}
module.exports.makeNoise = bark;
How would you access the functionality from another file?- Aconst dog = require("./dog");
dog.makeNoise(); - Bconst dog = require("./dog");
dog.bark();
- Aconst dog = require("./dog");
196If I had a file tweets.js and wanted to require it in another JavaScript file in the same directory would this work?
const tweets = require("tweets");
- ANo
- BYes
197The String object is what type of object?
- ANative
- BHost
198The HTTPS (https) API is available in which environment?
- ANode.js
- BThe Browser
199What method can you call on a buffer to convert it to a string?
- Astring();
- Bstringify()
- CmakeString()
- DtoString()
200Given the following code...
const https = require('https');
try {
const request = https.get('myawesomeapi.com/comments.json', (response) => {
});
request.on(error => console.error('Asynchronous error') );
} catch(error) {
console.error('URL parse error');
}
Which error will be triggered?- AAsynchronous error
- BURL parse error
Information
- Description
- Coding Quiz on JavaScript Review Part 1, created by Scot Pfleghaar on 10/08/2017.
- Author
- Scot Pfleghaar
- Language
- English
- Views
- 35
- Tags
- Rating
- No ratings yet Rate this quiz