JavaScript selftest

What is a self invoked function?
Please select exactly one correct alternative.

Answer

A self invoked function is a function that is stored within a JavaScript variable.
What value is valid considering the pattern "/\d{3,4}/g"?
Please select exactly one correct alternative.

Answer

The expression checks for number strings of 3 to 4 digits.
What does the unshift() method do?
Please select exactly one correct alternative.

Answer

The unshift() method adds new items to the beginning of an array.
What is the correct method to add new items at the end of an array?
Please select exactly one correct alternative.

Answer

The push() method adds new items to the end of an array.
What is prototypical inheritance?
Please select exactly one correct alternative.

Answer

Prototypical inheritance means that child scopes prototypically inherit from their parents.
What best describes a JavaScript scope?
Please select exactly one correct alternative.

Answer

Scope is the set of variables, objects, and functions you have access to.
Which statements below are correct on scopes and variables?
Please select none ore more correct alternatives.

Answer

Please see the correct answer above.
Which statements below are correct on scopes and variables?
Please select none ore more correct alternatives.

Answer

Please see the correct answer above.
Which statements below are correct on scopes and variables?
Please select none ore more correct alternatives.

Answer

Please see the correct answer above.
What is
defer
in
<script src="myscript.js" defer></script>
used for?
Please select exactly one correct alternative.

Answer

defer
Indicates that the script will not run until after the page has been loaded.
What will this code do?
Consider the following code:
<script>

    function myFunction() {
        vMyVar = "Hello HansR!";
    }
    
    alert(vMyVar);

</script>
What will this result into?
Please select exactly one correct alternative.

Answer

You have not defined the variable, so your browser will throw an error on it.
What will this code do?
Consider the following code:
<script>

    vMyVar = "Hello HansR!";
 
 myFunction();
 
    function myFunction() {
        alert(vMyVar);
    }

</script>
What will this result into?
Please select exactly one correct alternative.

Answer

You correctly declared the variable and have given it a value. So it will display this value.
What will this code do?
Consider the following code:
<script>

 myFunction();
 
    function myFunction() {
        alert(vMyVar);
    }
 
    var vMyVar = "Hello HansR!";

</script>
What will this result into?
Please select exactly one correct alternative.

Answer

The variable has not been given a value before you used it, so the value is undefined.
What is
async
in
<script src="myscript.js" async></script>
used for?
Please select exactly one correct alternative.

Answer

async
Indicated that the script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing).
How does your browseer handle an external JavaScript when neither defer nor asyn is present in
<script src="myscript.js"></script>
?
Please select exactly one correct alternative.

Answer

If neither async or defer is present: The script is fetched and executed immediately, before the browser continues parsing the page.
What is the difference between split() and splice()?
Please select exactly one correct alternative.

Answer

split()
operates on strings and
splice()
operates on arrays.
Which code fragment presents a correct way to walk through an array?
Please select exactly one correct alternative.

Answer

Array indices go from 0 to length - 1 in JavaScript.
What is the splice() function used for?
Please select exactly one correct alternative.

Answer

The splice() method changes the content of an array by removing existing elements and/or adding new elements, as in the example below.
var vMyArray = ["First", "Second", "Third"];
vMyArray.splice(2, 0, "New third", "New fourth");
     

The result of vMyArray will be:
First,Second,New third,New fourth,Third
     
Which statements are correct on null, empty, undefined in JavaScript?
Please select none ore more correct alternatives.

Answer

Please see the correct answer above.
How can you test whether a variable is undefined?
Please select exactly one correct alternative.

Answer

if (vMyVar === undefined) { vMessage = "vMyVar undefined"; } else { vMessage = "vMyVar defined"; }
is the correct way. Using == is not good idea there because in JavaScript, you can name a variable as undefined too.
Which code fragment presents a correct way to walk through an array?
Please select exactly one correct alternative.

Answer

An index for a JavaScript array runs from 0 to length - 1. Hence, the correct way to walk through an array is:
(vIndex = 0; vIndex < vArray.length; ++vIndex)
.
What is the difference between == and === in JavaScript expressions?
Please select exactly one correct alternative.

Answer

=== Means: equal value and equal type, == only means equal.
Which of the below are correct statements on JavaScript?
Please select none ore more correct alternatives.

Answer

Please see the resources below.

Reading

JavaScript
Where can you place your JavaScript in your web page?
Please select exactly one correct alternative.

Answer

Scripts can be placed in the <body>, or in the <head> section of an HTML page, or in both.
Which are correct examples for comments in JavaScript?
Please select none ore more correct alternatives.

Answer

Comments can be placed in between <!-- and --> or after // in JavaScript.
What are advantages of putting your JavaScript code into an external .js file?
Please select none ore more correct alternatives.

Answer

Placing JavaScripts in external files has some advantages:
  • It separates HTML and code.
  • It makes HTML and JavaScript easier to read and maintain.
  • Cached JavaScript files can speed up page loads.
What will this code result into?
You have following external JavaScript file and you include this file into your web page.
<script>
alert("Hello world!");
</script>
What will this result into?
Please select exactly one correct alternative.

Answer

Loading your web page in a browser will result in an error message because external scripts cannot contain <script> tags.
What is the difference between setTimeout and setInterval?
Please select exactly one correct alternative.

Answer

Both functions execute a given function in a given time. But setTimeout only executes this function once, while setInterval schedules a repeating execution.
Why is it not recommended to have many setInterval/setTimeout at the same time?
Please select exactly one correct alternative.

Answer

They cost a lot of CPU time. This could make your browser slow. Ofcourse, this depends on the processing power of your machine. In general, mobile devices are slower than e.g. desktop devices. It is preferred that a single setInterval / setTimeout call manages multiple animations.
What is Modernizr and what is it's purpose?
Please select exactly one correct alternative.

Answer

Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user's browser.
Taking advantage of cool new web technologies is great fun, until you have to support browsers that lag behind. Modernizr makes it easy for you to write conditional JavaScript and CSS to handle each situation, whether a browser supports a feature or not.
Which of the below are correct statements on JavaScript?
Please select none ore more correct alternatives.

Answer

You can use the sites below to learn about this topic.

Reading

JavaScript
Which of the following statements are correct on JavaScript output functions?
Please select none ore more correct alternatives.

Answer

Please see the correct answer above.
When using the
console.log
function in IE, please make sure that the console has been opened first. If not, IS will give an error message.
How can you minimize the global namespace pollution in JavaScript?
Please select exactly one correct alternative.

Answer

Please see the correct answer above.
Which method should you use when you want to delete an entry in a JavaScript array?
Please select exactly one correct alternative.

Answer

Please see the correct answer above.
What is a JavaScript promise?
Please select exactly one correct alternative.

Answer

An AngularJS promise (or just a JavaScript promise) is a way for handling asynchronous operations.

Reading

Promise

Geen opmerkingen:

Een reactie posten