473,651 Members | 3,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JavaScript knowledge test

Maybe anyone know good free online JavaScript knowledge test? This not
exactly a system for testing online required - it may be simply list
of questions with variants of answers (I have to prepare tests for
learners and I need something to be taken as basis).

I was able to find only this (http://www.w3schools.com/js/
js_quiz.asp), but I need more.

Thanks,
Mykola

Jul 31 '07
60 4980
On 31 , 18:29, Peter Michaux <petermich...@g mail.comwrote:
>
http://blog.meebo.com/?page_id=254

Peter
Thanks for link, Peter.

This is interesting but I can't use it :(. My task is to test
understanding of JavaScript fundamentals and skills to use it in real
life applications. I am not going to reveal concealed gurus :)

Aug 1 '07 #11
On 1 , 02:43, "Richard Cornford" <Rich...@litote s.demon.co.uk>
wrote:
When the question of seeking javascript tests on the interment comes up
my imagination usually conjures up an individual who thinks they will be
able to get away with using other people's code and copy-pasting their
way though life, if only they could get a foot through the door.
Preferably into a job where they were the only person creating the
javascript, and so not have anyone looking over their shoulders that
knew what they were doing. The good thing about such a position is that
the people doing the interview would not know what questions they should
be asking and so would likely get any technical test they used off the
Internet themselves. And so a thorough search for such tests, and the
rote learning of the 'correct' answers, might get them past the
technical test and into such a job.

But then I am very cynical.
Yes, you are. And your accusation is unjust. I am not interviewer. My
task is not to make learner out a fool but to test comprehension of
studied materials. I will never use questions I could not answer
myself. I know JavaScript a little more than my co-workers so I need
to organize teaching. I collected materials to study and I have to
test how they learned it. And before I will start to "invent bicycle"
I asked an advice.
/* unknown global code */
function outerFunction() {
/* unknown outer function body code */
function innerFunction() {
/* unknown inner function body code */
with(anObjectRe ference){
x = 5; //<--- The subject line of code.
}
/* more unknown inner function body code */
}
/* more unknown outer function body code */}

/* more unknown global code */
If I were HR manager I most likely do not hire a person who writes
code in that manner. Not because I am afraid of people who know more
than me. Gurus come and go but code leaves. Practice shows that
unmaintable code worse than inefficient code.
Aug 1 '07 #12
On Aug 1, 9:43 am, "Richard Cornford" <Rich...@litote s.demon.co.uk>
wrote:
[...]
"Inspired" by one of the more ambiguous questions on your meebo.com page
I thought the following might make quite interesting written test
questions, and give an impression of my thought process in setting
javascript questions:-
It seems few others are prepared to attempt a response, so I will.
Fools rush in and all that...

/* unknown global code */
function outerFunction() {
/* unknown outer function body code */
function innerFunction() {
/* unknown inner function body code */
with(anObjectRe ference){
x = 5; //<--- The subject line of code.
}
/* more unknown inner function body code */
}
/* more unknown outer function body code */}

/* more unknown global code */

/* *************** *************** *************** ***********\
| Note: Three facts about the 'unknown' code:- |
| |
| 1. There are no more function definitions, no function |
| expressions and no uses of the Function constructor. |
| 2. There are no - with - statements in the unknown code.|
| 3. There are no uses of the - eval - function. |
\************** *************** *************** ************ */

Q1: Assuming the line that reads - x = 5; - is executed, which (group
of) of the following are possible outcomes of its execution?
The argument passed to a with statement is first evaluated, then an
attempt is made to see if the result is an object reference. If so, it
is placed at the top of the scope chain. Identifier resolution of the
statement in question then proceeds against this augmented scope
chain.

1. The creation of an 'x' property of the 'outerFunction' function
and the assignment of the value 5 to that property.
Not possible. If a property x is created anywhere by that line, it
will be on the global object.

2. The assignment of the value 5 to a pre-existing 'x' property of
the 'outerFunction' function.
Possible, if anObjectReferen ce does not have an x property.

3. The creation of an 'x' property of the 'innerFunction' function
and the assignment of the value 5 to that property.
Not possible, see answer to 1.

4. The assignment of the value 5 to a pre-existing 'x' property of
the 'innerFunction' function.
Not possible, the innerFunction function object might have an x
property, but it isn't on the scope chain. However, innerFunction's
execution object (which is on the scope chain) may have an x property
if one's been declared and that could be assigned a value.

5. The creation of an 'x' property of the object referred to by
'anObjectRefere nce' and the assignment of the value 5 to that
property.
Not possible, see 1.

6. The assignment of the value 5 to a pre-existing 'x' property of
the object referred to by 'anObjectRefere nce'.
Possible, the usual intended result.

7. The creation of a local variable of the 'outerFunction' function
named 'x' and the assignment of the value 5 to that variable.
Not possible, see 1 again.

8. The assignment of the value 5 to a declared local variable of the
'outerFunction' function named 'x'.
Possible, since that is on the scope chain.

9. The creation of a local variable of the 'innerFunction' function
named 'x' and the assignment of the value 5 to that variable.
Not possible, the creation thing again, see 1.

10. The assignment of the value 5 to a declared local variable of the
'innerFunction' function named 'x'.
Possible, innerFunction's execution object is on the scope chain.

11. The creation of a global variable named 'x' and the assignment of
the value 5 to that variable.
Possible if x is not encountered sooner in the scope chain, see 1.
Unless you are splitting hairs by saying that properties created this
way aren't variables because they aren't declared, they are just
properties.

12. The assignment of the value 5 to a declared global variable
named 'x'.
Possible, see 11.

13. The creation of an 'x' property of the global object and the
assignment of the value 5 to that property.
Possible, see 11. If all else fails...

14. The assignment of the value 5 to a pre-existing 'x' property of
the global object.
Possible, not much different to 12: declaring x as a global variable
makes it pre-existing to the execution of any code.

15. The creation of an 'x' property of the window object and the
assignment of the value 5 to that property.
Possible, where window === global (which should be always for
browsers), as for 11.

16. The assignment of the value 5 to a pre-existing 'x' property of
the window object.
Possible, see 14 & 15.

17. A runtime error.
Possible if anObjectReferen ce isn't an object.

Q2: If the line of code above is changed from - x = 5; - to - var x =
5 - which (group of) the above are then the possible outcomes of the
execution of that line?
x becomes a property of the innerFunction activation object, the only
possible outcomes are that the value will be assigned to an existing
property anObjectReferen ce, or if that doesn't exist, innerFunction's
declared local x. The resolution of x will proceed no further so no
other outcome will occur.

I would have to go over the answers with the candidate taking the test
as there are a number of 'understandable mistakes' to be easily made
here (that is, getting some of them wrong is a certain fail, but others
may need the thinking behind the answer.)
Hopefully my explanations are sufficient where the answer itself
isn't.
--
Rob

Aug 1 '07 #13
On Aug 1, 5:32 pm, marss <marss...@gmail .comwrote:
On 1 , 02:43, "Richard Cornford" <Rich...@litote s.demon.co.uk>
wrote:
[...]
/* unknown global code */
function outerFunction() {
/* unknown outer function body code */
function innerFunction() {
/* unknown inner function body code */
with(anObjectRe ference){
x = 5; //<--- The subject line of code.
}
/* more unknown inner function body code */
}
/* more unknown outer function body code */}
/* more unknown global code */

If I were HR manager I most likely do not hire a person who writes
code in that manner. Not because I am afraid of people who know more
than me. Gurus come and go but code leaves. Practice shows that
unmaintable code worse than inefficient code.
That pattern is common where the intention is to emulate private
methods or to encapsulate a library of functions, though it is
normally written something like:

var outerFunction = (function()
{
function innerFunction() {...}

/*
** code that calls innerFunction
*/

})();

The intention of Richard's question is not to encourage any particular
code style or use of the with statement (or even to show off), but to
propose a set of questions to determine someone's understanding of
basic identifier resolution against the scope chain. The use of a
reasonably common code pattern tests if they can apply that knowledge.

It may also test if they can read the ECMAScript Language spec and
apply it, supposing they are as unfamiliar with the with statement as
the great majority of those here seem to be (and I count myself as one
of them).

If you are an HR manager and not a programmer, get someone who you
trust to hire programmers. :)

What's more dangerous, a manager who codes or a programmer with a
soldering iron?

--
Rob.

Aug 1 '07 #14
Hi Rob,

Not that I think I'm a qualified know-it-all but in the spirit of
discussion...

On Aug 1, 6:50 am, RobG <rg...@iinet.ne t.auwrote:
2. The assignment of the value 5 to a pre-existing 'x' property of
the 'outerFunction' function.

Possible, if anObjectReferen ce does not have an x property.
I think the only way to set a prexisting x *property* of outerFunction
would be if anObjectReferen ce refers to outerFunction. In this case
anObjectReferen ce would have an x property.

4. The assignment of the value 5 to a pre-existing 'x' property of
the 'innerFunction' function.

Not possible, the innerFunction function object might have an x
property, but it isn't on the scope chain. However, innerFunction's
execution object (which is on the scope chain) may have an x property
if one's been declared and that could be assigned a value.
If anObjectReferen ce refers to the innerFunction object then the
properties of innerFunction are in the scope chain.

17. A runtime error.

Possible if anObjectReferen ce isn't an object.
But this runtime error isn't due to the subject line of code. It is
due to the line before it.

Peter

Aug 1 '07 #15
On Jul 31, 4:43 pm, "Richard Cornford" <Rich...@litote s.demon.co.uk>
wrote:
>
"Inspired" by one of the more ambiguous questions on your meebo.com page
I thought the following might make quite interesting written test
questions, and give an impression of my thought process in setting
javascript questions:-

/* unknown global code */
function outerFunction() {
/* unknown outer function body code */
function innerFunction() {
/* unknown inner function body code */
with(anObjectRe ference){
x = 5; //<--- The subject line of code.
}
/* more unknown inner function body code */
}
/* more unknown outer function body code */}

/* more unknown global code */

/* *************** *************** *************** ***********\
| Note: Three facts about the 'unknown' code:- |
| |
| 1. There are no more function definitions, no function |
| expressions and no uses of the Function constructor. |
| 2. There are no - with - statements in the unknown code.|
| 3. There are no uses of the - eval - function. |
\************** *************** *************** ************ */
I started thinking about strings in JavaScript that can be used like
eval() or the function constructor. I think that no use of
setTimeout() or setInterval() with a string first argument should be
added to the list of facts also.

Aug 1 '07 #16
Richard Cornford wrote:
"Inspired" by one of the more ambiguous questions on your meebo.com page
I thought the following might make quite interesting written test
questions, and give an impression of my thought process in setting
javascript questions:-

/* unknown global code */
function outerFunction() {
/* unknown outer function body code */
function innerFunction() {
/* unknown inner function body code */
with(anObjectRe ference){
x = 5; //<--- The subject line of code.
}
/* more unknown inner function body code */
}
/* more unknown outer function body code */
}
/* more unknown global code */

/* *************** *************** *************** ***********\
| Note: Three facts about the 'unknown' code:- |
| |
| 1. There are no more function definitions, no function |
| expressions and no uses of the Function constructor. |
| 2. There are no - with - statements in the unknown code.|
| 3. There are no uses of the - eval - function. |
\************** *************** *************** ************ */
Q1: Assuming the line that reads - x = 5; - is executed, which (group
of) of the following are possible outcomes of its execution?

1. The creation of an 'x' property of the 'outerFunction' function
and the assignment of the value 5 to that property.
Not possible. For the creation of a property of a Function object that
object needs to be referenced explicitly.
2. The assignment of the value 5 to a pre-existing 'x' property of
the 'outerFunction' function.
Not possible. For the assignment to a property of a Function object
that object needs to be referenced explicitly.
3. The creation of an 'x' property of the 'innerFunction' function
and the assignment of the value 5 to that property.
Same here.
4. The assignment of the value 5 to a pre-existing 'x' property of
the 'innerFunction' function.
And here.
5. The creation of an 'x' property of the object referred to by
'anObjectRefere nce' and the assignment of the value 5 to that
property.
At least unlikely. The ambiguity in the `with' statement is that it
usually does not apply to assignment statements without a
VariableReferen ce left-hand side. Which is why it is deprecated.
6. The assignment of the value 5 to a pre-existing 'x' property of
the object referred to by 'anObjectRefere nce'.
Same here.
7. The creation of a local variable of the 'outerFunction' function
named 'x' and the assignment of the value 5 to that variable.
Not possible. For the creation of local variables requires a local
VariableStateme nt, however a VariableStateme nt would make the variable
one of innerFunction() .
8. The assignment of the value 5 to a declared local variable of the
'outerFunction' function named 'x'.
Possible. The innerFunction() function must not have a local `x'
variable then.
9. The creation of a local variable of the 'innerFunction' function
named 'x' and the assignment of the value 5 to that variable.
Not possible for the reasons given for 7.
10. The assignment of the value 5 to a declared local variable of the
'innerFunction' function named 'x'.
Possible.
11. The creation of a global variable named 'x' and the assignment of
the value 5 to that variable.
Possible if neither innerFunction() nor outerFunction() have a variable
with that name declared.
12. The assignment of the value 5 to a declared global variable
named 'x'.
Same here.
13. The creation of an 'x' property of the global object and the
assignment of the value 5 to that property.
Possible. Global variables are properties of the Global Object, because
that is the Variable Object of the global execution context.
14. The assignment of the value 5 to a pre-existing 'x' property of
the global object.
Possible if neither innerFunction() nor outerFunction() have a variable
with that name declared.
15. The creation of an 'x' property of the window object and the
assignment of the value 5 to that property.
Possible, although the outcome is implementation- and context-dependent.
The host-defined `window' property of the Global Object may not refer
to the Global Object, of which the `x' property would be a property of
under the conditions mentioned for 14.
16. The assignment of the value 5 to a pre-existing 'x' property of
the window object.
Same here.
17. A runtime error.
Possible if x was not declared before and x is an ID or a name of a DOM
object of the IE DOM (MSHTML component). I can also think of broken
implementations that would not allow a variable to have the same ID or
name as a DOM object.
Q2: If the line of code above is changed from - x = 5; - to - var x =
5 - which (group of) the above are then the possible outcomes of the
execution of that line?
9 and 10.
I would have to go over the answers with the candidate taking the test
as there are a number of 'understandable mistakes' to be easily made
here (that is, getting some of them wrong is a certain fail, but others
may need the thinking behind the answer.)
I am looking forward to your evaluation of my answers.
Regards,
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Aug 1 '07 #17
On Aug 2, 2:56 am, Peter Michaux <petermich...@g mail.comwrote:
Hi Rob,

Not that I think I'm a qualified know-it-all but in the spirit of
discussion...

On Aug 1, 6:50 am, RobG <rg...@iinet.ne t.auwrote:
2. The assignment of the value 5 to a pre-existing 'x' property of
the 'outerFunction' function.
Possible, if anObjectReferen ce does not have an x property.

I think the only way to set a prexisting x *property* of outerFunction
would be if anObjectReferen ce refers to outerFunction. In this case
anObjectReferen ce would have an x property.
4. The assignment of the value 5 to a pre-existing 'x' property of
the 'innerFunction' function.
Not possible, the innerFunction function object might have an x
property, but it isn't on the scope chain. However, innerFunction's
execution object (which is on the scope chain) may have an x property
if one's been declared and that could be assigned a value.

If anObjectReferen ce refers to the innerFunction object then the
properties of innerFunction are in the scope chain.
My logic was faulty on both questions - I never considered that
anObjectReferen ce might be to inner/outerFunction. So I got 2 "right"
by accident, and 4 wrong on purpose. I think the tedium got to me!

17. A runtime error.
Possible if anObjectReferen ce isn't an object.

But this runtime error isn't due to the subject line of code. It is
due to the line before it.
Which means that the line itself is never executed - perhaps a
question along those lines would be more appropriate. It would also
be more difficult to fathom, most people are unlikely to consider
runtime errors as a strategy for preventing particular lines of code
from executing :-).
--
Rob

Aug 1 '07 #18
RobG wrote:
On Aug 2, 2:56 am, Peter Michaux <petermich...@g mail.comwrote:
>On Aug 1, 6:50 am, RobG <rg...@iinet.ne t.auwrote:
>>>2. The assignment of the value 5 to a pre-existing 'x' property of
the 'outerFunction' function.
Possible, if anObjectReferen ce does not have an x property.
I think the only way to set a prexisting x *property* of outerFunction
would be if anObjectReferen ce refers to outerFunction. In this case
anObjectRefere nce would have an x property.
>>>4. The assignment of the value 5 to a pre-existing 'x' property of
the 'innerFunction' function.
Not possible, the innerFunction function object might have an x
property, but it isn't on the scope chain. However, innerFunction's
execution object (which is on the scope chain) may have an x property
if one's been declared and that could be assigned a value.
If anObjectReferen ce refers to the innerFunction object then the
properties of innerFunction are in the scope chain.

My logic was faulty on both questions - I never considered that
anObjectReferen ce might be to inner/outerFunction. [...]
However, Peter is mistaken here. The `with' statement does not apply to
the left-hand side of this assignment, no matter the object referenced
with anObjectReferen ce. Unless x is declared, it will always reference
a property of the Global Object, that is a global variable. And so it
will either create that, modify it, or due to the peculiarities of an
execution environment cause a runtime error.
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Aug 1 '07 #19
On Aug 1, 2:04 pm, RobG <rg...@iinet.ne t.auwrote:
>
17. A runtime error.
Possible if anObjectReferen ce isn't an object.
But this runtime error isn't due to the subject line of code. It is
due to the line before it.

Which means that the line itself is never executed - perhaps a
question along those lines would be more appropriate. It would also
be more difficult to fathom, most people are unlikely to consider
runtime errors as a strategy for preventing particular lines of code
from executing :-).
Oddly enough . . . I've done this! I considered run-time errors due to
a browser bug/limitation to determine which versions of a particular
old browser could make an XHR POST. This was probably the weirdest
feature test I've ever made but avoided a use of navigator.userA gent.

// NN6.2 can't make POST requests because can't have arguments to
send()
// so now catch NN6.2 and any other browsers that can't take
argument to XHR.send()
function cannotPost() {
var xhr = new XMLHttpRequest( );
try {
xhr.send("asdf" );
} catch (e) {
// All calls to xhr.send() should error because there wasn't a
call to xhr.open()
// however the normal error is something about "not initialized"
as expected
// since xhr.open() was not called. NN6.2 gives a different
error indicating
// xhr.send() cannot take arguments.
if (-1 !== e.toString().in dexOf("Could not convert JavaScript
argument arg 0 [nsIXMLHttpReque st.send]")) {
return true;
}
}
return false;
}
Peter

Aug 1 '07 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
4212
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is avaliable at... http://www.geocities.com/binnyva/code/javascript/advanced_tutorial/ If any of you could spare the time, please have a look at my tutorial
136
9301
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8584
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.