JAVASCRIPT Exam Questions and Answers Latest Graded A+, Exams of Javascript programming

JAVASCRIPT Exam Questions and Answers Latest Graded A+

Typology: Exams

2025/2026

Available from 05/18/2026

DrBenard
DrBenard 🇺🇸

3.5K documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
JAVASCRIPT Exam Questions and Answers Latest Graded A+
What must a variable begin with? - ✔✔A letter, $ or _
What is a variable? - ✔✔Container for a piece of data
Are variables case sensitive? - ✔✔Yes
How do you declare variables? - ✔✔using the var keyword - eg. var myName="Monica";
What will an undeclared variable return? - ✔✔Undefined
Two types of variable scope? - ✔✔Local and Global
What are the properties of a Local Scope? - ✔✔Within a function, only available within function
What are the properties of Global Scope? - ✔✔Outside a function, available to any code outside that
function (also within).
What is Variable "Hoisting"? - ✔✔Variables are hoisted to the top of the function/statement. It is useful
because you can refer to variables declared later in the code.
What is best practice regarding variable declarations? - ✔✔Put variable declarations as close to the top of
the scope as possible.
Prototype Based - ✔✔Each object has a prototype that it inherits properties and abilities from
Dynamic Typing - ✔✔Dynamic if the type of variable is interpreted at runtime.
First Class Function - ✔✔Treats functions as first class citizens - you can do with functions everything
you can do with other elements.
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download JAVASCRIPT Exam Questions and Answers Latest Graded A+ and more Exams Javascript programming in PDF only on Docsity!

JAVASCRIPT Exam Questions and Answers Latest Graded A+

What must a variable begin with? - ✔✔A letter, $ or _ What is a variable? - ✔✔Container for a piece of data Are variables case sensitive? - ✔✔Yes How do you declare variables? - ✔✔using the var keyword - eg. var myName="Monica"; What will an undeclared variable return? - ✔✔Undefined Two types of variable scope? - ✔✔Local and Global What are the properties of a Local Scope? - ✔✔Within a function, only available within function What are the properties of Global Scope? - ✔✔Outside a function, available to any code outside that function (also within). What is Variable "Hoisting"? - ✔✔Variables are hoisted to the top of the function/statement. It is useful because you can refer to variables declared later in the code. What is best practice regarding variable declarations? - ✔✔Put variable declarations as close to the top of the scope as possible. Prototype Based - ✔✔Each object has a prototype that it inherits properties and abilities from Dynamic Typing - ✔✔Dynamic if the type of variable is interpreted at runtime. First Class Function - ✔✔Treats functions as first class citizens - you can do with functions everything you can do with other elements.

Multi Paradigm Language - ✔✔Supports more than one programming paradigm - developers can work with a variety of styles within javascript. DOM - ✔✔Document Object model. What is DOM? - ✔✔Representation of HTML Page.... What are the two ways to add JS to your site? - ✔✔Internally and Externally. How do you add JS To your site internally? - ✔✔Internally using html tag. Best practice to place it before closing body tag. How do you add JS to your site externally? - ✔✔Add by externally linking to .js files. Is JS case sensitive? - ✔✔Yes JS Statement - ✔✔A command that tells the browser what to do. document.write("hello world"); var myName="lorna"; Can a statement be grouped into useable blocks called functions? - ✔✔Yes. Datatypes - ✔✔Numbers, Strings, Boolean, Arrays, Objects. What are the 2 types of Numbers within Datatypes? - ✔✔Integer: Whole Number (-1, 450) Float:Decimal Point (0.1, 12.454)

Conditionals - ✔✔Statements that allow for code to be executed against conditionals IF, ELSE statements Example of Conditional IF Statement - ✔✔if (This condition is true) {Do this thing} var Country = "Australia"; var Hemisphere, var Language; if (country = "England") { hemisphere = "northern"; language = "english"; } Example of Conditional ELSE Statement - ✔✔Else statements allow us to make an alternative statement if original condition is false if (this condition is true){ ...do this thing }else{ ...do this other thing } Loops - ✔✔Repetitive Conditional statements. Used to perform a calculation a number of times, or to iterate over a set of variables. Three main types of Loops - ✔✔For: Set Number of Iterations While: Certain conditions are met

Do...While: Certain condition is met For Loop Example - ✔✔Repeats until a specific condition becomes false While Loop Example - ✔✔Iterate while the condition is true while (condition) { do this thing } Do While Loop - ✔✔Iterate while the condition is true do { ... this thing } while(condition); Function - ✔✔Re-useable blocks of instructions that can be executed by name.

  • Perform common tasks
  • saves time, reduces error function functionName (data) { repeat action here return outcome } Function Example - ✔✔function sayHello(){ alert ("hello everyone!");
  • ✔✔It will change the text between the

    tags to the content in quotes after x.innerHTML Hello JavaScript! What does this piece of code tell the computer to do? x=document.getElementById("demo") - ✔✔Find the Element ("demo"); document.getElementById("some id") (The "Id" could be anything else.) What does this piece of code tell the computer to do? x.innerHTML="Hello JavaScript!"; - ✔✔Change the content of the x variable to Hello JavaScript! parseInt: If the first character cannot be converted to a number, what is returned? - ✔✔NaN What does parseFloat do? - ✔✔It parses its argument, and returns a floating point number. If it encounters a character other than a sign (+ or - ), numeral (0-9), a decimal point, or an exponent, it returns the value up to that point and ignores that character and all succeeding characters. Leading and trailing spaces are allowed. Math.random() - ✔✔This function returns a floating-point, pseudo-random number in the range 0 to 1 — that is, from 0 (inclusive) up to but not including 1 (exclusive) — which you can then scale to your desired range. The implementation selects the initial seed to the random number generation algorithm; it cannot be chosen or reset by the user. What is the DOM? - ✔✔The DOM is a representation of a webpage that JavaScript can use. Object Prototype - ✔✔function Person(first, last, age, eyecolor) {

this.firstName = first; this.lastName = last; this.age = age; this.eyeColor = eyecolor; Which index is zero based? (The first element is 0, the second is 1, and so on.) - ✔✔Array pop() - ✔✔Removes the last element of an array, and returns that element push() - ✔✔Adds new elements to the end of an array, and returns the new length shift() - ✔✔Removes the first element of an array, and returns that element splice() - ✔✔adds/removes items to/from an array, and returns the removed item(s) unshift() - ✔✔Adds new elements to the beginning of an array, and returns the new length children - ✔✔children property returns a collection of an element's child elements, as an HTMLCollection object The elements in the collection are sorted as they appear in the source code and can be accessed by index numbers. The index starts at 0. childNodes - ✔✔The childNodes property returns a collection of a node's child nodes, as a NodeList object. The nodes in the collection are sorted as they appear in the source code and can be accessed by index numbers. The index starts at 0. Note: Whitespace inside elements is considered as text, and text is considered as nodes. Comments are also considered as nodes.

.innerHTML - ✔✔can read and alter the elements on a webpage return - ✔✔ends function execution and specifies a value to be returned to the function caller ternary - ✔✔this.items = items !== undefined? items : []; (if items is undefined, return items; otherwise return the array)

  • ✔✔for loop that prints all items in array
  • ✔✔for of loop that prints all items in array

// jQuery // $.each(toys, function(index, value){ // console.log(value); // });

  • ✔✔The $.each() function internally retrieves and uses the length property of the passed collection. button.addEventListener('click', () => { p.innerHTML = input.value + ':'; }); - ✔✔When the button is clicked, the text between the

    tags is changed per what is typed into input box What is a dataset? - ✔✔The dataset property on the HTMLElement interface provides read/write access to all the custom data attributes (data-*) set on the element. This access is available both in HTML and within the DOM. It is a map of DOMString, one entry for each custom data attribute. Math.floor() - ✔✔A function that returns the largest integer less than or equal to a given number. parseFloat() - ✔✔This function parses a string and returns a floating point number. This function determines if the first character in the specified string is a number. If it is, it parses the string until it reaches the end of the number, and returns the number as a number, not as a string. parseInt() - ✔✔This function parses a string and returns an integer. (Only the first number gets returned.) Node properties to navigate between nodes with JavaScript - ✔✔parentNode, childNodes[nodenumber], firstChild, lastChild, nextSibling, previousSibling A common error in DOM processing - ✔✔to expect an element node to contain text

In terms of DOM, = - ✔✔document.head elem.childNodes[0] === - ✔✔elem.firstChild elem.childNodes[elem.childNodes.length - 1] === - ✔✔elem.lastChild elem.hasChildNodes() - ✔✔used to check whether there are any child nodes childNodes - ✔✔It looks like an array but it's not. It's a collection - a special array-like iterable object