Request Dev Services » / Notes /

Random JavaScript Trivia (Did you know these?)

How much JavaScript do you really know? Did you know this JS trivia?

What is the root element of an HTML document?


What is a function that the processing tier does not handle in a three-tier client/server system?

Data Storage

What is an example of an invalid identifier?


What is a library?

A library is essentially a collection of pre-written code, short-cuts, and functionalities built, packaged, optimized, and maintained by a bunch of other developers. A very popular library example would be jQuery, but in regards to javaScript there are many these days.

What is an example of a primitive data type in JavaScript?


What describes JavaScript?

Strongly typed

Write a simple function that contains name, params, and function braces:

function mrCameron(job) {
     document.getElementById("code").innerHTML = "JavaScript";

Explain the difference between prefix and postfix operators, and provide an example of each.

Prefix: If used prefix with operator before operand (i.e., ++Cameron), then it returns value after incrementing.

Postfix: If used postfix, with operator after operand (i.e., Cameron++), then it returns the value before incrementing.

Explain the usage of a ternary operation.

If condition is true, the ternary operator will return the value of the first expression; otherwise, it returns the value of the second expression. Basically, a short-hand inline if else statement.

What property returns the number of elements in an array?


What is an example of a statement that always execute at least once?


The statement halts a looping statement and restarts the loop with a new iteration.


Explain what causes an infinite loop, and what you can to do ensure that your programs do not contain infinite loops.

An infinite loop is a sequence of instructions in a program which loops endlessly, either due to the loop having no terminating condition, having one that can never be met, or one that causes the loop to start over. To avoid, add terminating conditions that can be met.

What does an else if statement replace? What are the advantages of using an else if statement?

The advantage of an ELSE IF, …, ELSE type structure is that the program stops checking further conditions if a condition is fulfilled. Multiple IF statements would work, however, it would continue to check the IF over and over again which isn’t very optimal. It could replace multiple IFs essentially.

What type of error occurs when the interpreter fails to recognize code?


What errors are problems in the design of a program that prevent it from running as you anticipate?


When a JavaScript interpreter encounters a problem while a program is executing, what kind of error is it?


The watch list in browser debugging tools lets you monitor the value of what during program execution?


When and why should you use exception handling with your JavaScript programs?

When; I’d say if you have a pretty JavaScript heavy program, perhaps with sensitive content or the necessity for 0 down time, and you may have multiple developers working within it – exception handling (error handling) may be a good idea. Why; Error handling may ‘try’ or ‘test’ code for programmer errors,  incorrect input or other unforeseen things. With error handling you can do things like print custom error messages and codes, useful for an expansive and fragile project.

Each item in the DOM tree is known as a what?


How do you increase the likelihood that a new window you create with the window . open() method will open as a new window rather than a new tab?

specify a height and/or a width value.

The properties of which object describe a user’s browser?


Which object allows you to change to a new, unvisited web page from within JavaScript code?


What value of the selectedIndex property of a select object corresponds to no selection?


Which event do you use to call a function when a user selects a field or moves the insertion point into a field?


For any fields that require numeric values, you can use JavaScript’s built-in what function to determine whether the user actually entered a number?


Which of the following properties has a value of true when a user has left a required field blank?


Explain how to check if any option button in a set is selected.

You could create and if condition using && operator to check against .checked.

About the Author
Cameron Cashwell Web Developer
I build websites, web apps, and software. Wanna work together? Let's chat about your project!

Leave a Reply

Be the First to Comment!

Notify of