Beruflich Dokumente
Kultur Dokumente
com has received a lot of responses to our job posting for a Dubai - Javascript
Developer. Since we have limited ressources we cannot interview everyone who has
applied for the job. This questionnaire is part of a pre-screening for a job interview.
Getting a reliable view of your skills is of utmost importance, hence you will be immediately
disqualified for the job, if we later discover that the online test does not match your own
knowledge. Therefore you have to complete the test on your own.
document.cookie = "foo=bar;secure";
What is Firebug?
○ A Javascript ajax/event/UI framework.
○ An add-on for Mozilla Firefox.
○ The plugin framework of Mozilla Firefox.
○ The Mozilla project's bug database.
Which of the following is not a popular Javascript
framework?
○ Ajaxian
○ Prototype
○ MooTools
○ Dojo
○ 10!
○ Nothing, it's an infinite loop.
○ 10 to the power of 10
○ 10!/10
○ The 10th Fibonacci number.
What is JSON?
○ A safe subset of Javascript.
○ A lightweight data interchange format.
○ All of the above.
○ None of the above.
○ The total will be incremented twice for fruit types that have already been
encountered in the list.
○ The lack of block scope in Javascript causes the second var num
assignment to overwrite the first one.
○ The numbers are interpreted as binary because the p arseInt function is
called with a wrong 'radix' parameter.
○ A for-in loop can only be used with arrays. The behavior is undefined
when used with objects.
○ An error in one of the regular expressions causes apples and oranges to
be considered the same fruit type.
Why doesn't the below code open an alert box with the text
"foo"?
function wrapInObject(value) {
return
{
value: value
};
}
alert(wrapInObject("foo").value);
Why doesn't the below code open an alert box with the text
"foobar"?
var a = "foo",
b = a;
b += "bar";
alert(a);
○ When bar has been appended to b, b and a don't refer to the same
value because strings are immutable in Javascript.
○ Because Javascript enforces referential integrity for primitive values.
○ Because there is a circular reference between the two String objects.
○ The += operator only works with numbers.
function f(a) {
return function(b) {
return a + b;
};
}
○ Given an integer a it returns an anonymous function that returns the sum
and the supplied argument b.
of a
○ Given a string a it returns an anonymous function that returns the
concatenation of a and the supplied argument b
.
○ All of the above.
○ None of the above.
function isFalseBooleanValue(bool) {
// return...
}
(function() {
for (var i=0 ; i<10 ; i++) {
alert(i);
}
})();
instead of just:
window.onload = function() {
document.write("Hello, world!");
};
document.body.appendChild(button).appendChild(document.createTextNod
e("Button "+i));
}
○ The variable i cannot be used in the onclick handler because it's defined
in an outer scope.
○ The variable i will be shared among the event handlers because
Javascript doesn't have block scope.
○ Button tags are only allowed within a < form>.
○ Chaining a ppendChild calls is only supported in Internet Explorer.
The below code doesn't work as expected. What could be
wrong? (Assuming that elements with a class of 'button'
receive a suitable styling)
function removeLeadingAndTrailingWhitespaceFromString(str) {
return str.replace(/(^\s+)|(\s+$)/ig, "");
}
function StateMachine(initialState) {
this.state = initialState || 'foo';
return {
transition: function() {
this.state = {foo:'bar', bar:'quux', quux:'foo'}[this.state];
return this;
}
};
}
var sm = new StateMachine();
alert(sm.transition().transition().state);
function StringBuffer(initialStr) {
this.append(initialStr);
}
StringBuffer.prototype = {
items: [],
append: function(str) {
this.items[this.items.length] = str instanceof StringBuffer ?
str.toString() : str;
return this;
},
toString: function() {
return this.items.join("");
}
};
alert(new StringBuffer("foo").append(new StringBuffer("bar")).toString());
function f(a, b) {
return function() {
return a.apply(b, arguments);
};
}
function printZeroToNinetyNine() {
for (var i = 0; i < 100; i += 1) {
setTimeout(function () {
console.log(i);
}, 0);
}
}
function delayedPrint() {
for (var i = 0; i < 100; i += 1) {
(function (value) {
setTimeout(function () {
console.log(i);
}, 1000 * value);
}(i));
}
}
returnObject[name] = value;
returnObject['addTo' + name] = function () {
return value += 1;
};
return returnObject;
}
function hasANumber(value) {
return /^.*[0-9]*.*$/.test(value);
}
○ It will not match strings that contain a decimal like 'abc 12.34'.
○ The * modifier after [0-9] means it will match for strings with no numbers.
○ \d should be used instead of [0-9].
○ The g flag is not set so it will not return true if there are multiple
numbers.
○ It will not match strings with numbers at the beginning or end like '123'.
tasks.forEach(function (task) {
task();
numTasks -= 1;
if (numTasks === 0) {
cb();
}
});
}
doInParallel([...], function () {
// Execute only when tasks are complete
});
obj.value = ???;
○ this
○ obj.value
○ function () {return true;}
○ obj
○ window
Given the below code, which of the following is true:
var a = '',
b = '',
c = {value1: a, value2: b},
d = {value2: b, value1: a};
○ element.style.backgroundColor = '#f00';
○ element.bg.color.red = true;
○ element.setBackgroundColor('#ff0000');
○ element.style({ background-color: red; })
○ element.style.background-color = red;