W
Walton
I'm wondering if anyone knows or knows where to find a collection of
javascript "brain teasers" for lack of a better description.
Companies use these types of tests for programmers all the time when
hiring. I've managed to find a few questions here and there.. for
example (i'll leave the following unanswered for your amusement):
*****NOTE -- i'm not interested in answers to these, just curious as
to where I can find some more.
-- When does div.setAttribute('attr', val) not equal div.attr = val?
-- What's the difference between these two statements:
1. var x = 3;
2. x = 3;
-- What's the difference between:
1. !!(obj1 && obj2)
2. (obj1 && obj2)
-- Write a one-line piece of JavaScript code that concatenates all
strings passed into a function:
function concatenate(/* any number of strings */) {
var string = /* your one line here */
return string;
}
-- What do these two examples have in common?
1. var obj = document.getElementById('adiv');
document.getElementById('adiv').ptr = obj;
2. function assignClick() {
var el = document.createElement('div');
function handleClick() { el.innerHTML = 'clicked!'; }
el.attachEvent('onclick', handleClick);
}
I love these things. If anyone can point me to some more, many thanks.
javascript "brain teasers" for lack of a better description.
Companies use these types of tests for programmers all the time when
hiring. I've managed to find a few questions here and there.. for
example (i'll leave the following unanswered for your amusement):
*****NOTE -- i'm not interested in answers to these, just curious as
to where I can find some more.
-- When does div.setAttribute('attr', val) not equal div.attr = val?
-- What's the difference between these two statements:
1. var x = 3;
2. x = 3;
-- What's the difference between:
1. !!(obj1 && obj2)
2. (obj1 && obj2)
-- Write a one-line piece of JavaScript code that concatenates all
strings passed into a function:
function concatenate(/* any number of strings */) {
var string = /* your one line here */
return string;
}
-- What do these two examples have in common?
1. var obj = document.getElementById('adiv');
document.getElementById('adiv').ptr = obj;
2. function assignClick() {
var el = document.createElement('div');
function handleClick() { el.innerHTML = 'clicked!'; }
el.attachEvent('onclick', handleClick);
}
I love these things. If anyone can point me to some more, many thanks.