Last active
August 29, 2015 14:18
-
-
Save XciA/c6d36621753c5922e269 to your computer and use it in GitHub Desktop.
UI developer question list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For candidates between 0.6-2 years | |
1) Anagram in Javascript | |
function compare(w1,w2){ | |
var word1 = w1.split("").sort().join(""); | |
var word2 = w1.split("").sort().join(""); | |
if(word1 === word2){ | |
console.log('anagrams'); | |
} | |
else{ | |
console.log('not anagrams'); | |
}} | |
compare('notices','section') | |
2)var role = { 'UI_developer' : 'UI Developer'}; | |
delete UI_developer from role object | |
expected - delete role.UI_developer | |
digging - Delete will not delete properties that are found on the prototype chain | |
3)var Skill = ['UI','Developer'] | |
var skillList = Skill.join(''); -> UI,Developer | |
where is join defined {Array.prototype.join} | |
join is not a property of skill yet its accessed { | |
method was added (among others) as a property of the prototype property of Array() | |
First It will look at the constructor function that created the object | |
(e.g. Array), and inspect its prototype (e.g. Array.prototype) to see if the property can be found | |
there. If the first prototype object does not have the property, then JavaScript keeps searching up the | |
chain at the constructor behind the initial constructor. | |
} | |
Ask | |
Object.prototype.foo = 'foo'; | |
var myString = 'bar'; | |
myString.foo --> ?? | |
4)var harish={ | |
'location' : 'Chennai', | |
'role' : 'Software Developer' | |
} | |
for (var key in harish){ | |
if(harish.hasOwnProperty(key)){console.log(key)} | |
} | |
5)for (x in window) {console.log(x); //logs all of the properties of the window/head object | |
} | |
6)Functions are invoked using four different scenarios or patterns. | |
✴ As a function | |
✴ As a method | |
✴ As a constructor | |
✴ Using apply() or call() | |
// apply() and call() pattern | |
var greet = { | |
runGreet: function(){ | |
console.log(this.name,arguments[0],arguments[1]); | |
} | |
} | |
var ramesh = {name:'ramesh'}; | |
var suresh = {name:'suresh'}; | |
// invoke the runGreet function as if it were inside of the ramesh object | |
greet.runGreet.call(ramesh,'foo','bar'); // logs 'ramesh foo bar' | |
// invoke the runGreet function as if it were inside of the suresh object | |
greet.runGreet.apply(suresh, ['foo','bar']); // logs 'suresh foo bar' | |
/* Notice the difference between call() and apply() in how parameters are sent to the | |
function being invoked */ | |
// function pattern | |
var myFunction = function(){return 'foo'}; | |
console.log(myFunction()); // log 'foo' | |
// method pattern | |
var myObject = {myFunction: function(){return 'bar';}} | |
console.log(myObject.myFunction()); // log 'bar' | |
// constructor pattern | |
var ramesh = function(){ | |
this.living = true; | |
this.age = 33; | |
this.gender = 'male'; | |
this.getGender = function() {return this.gender;}; | |
} | |
var ramesh = new ramesh(); // invoke via ramesh constructor | |
console.log(ramesh); // logs ramesh object and properties | |
7)var x = 10; | |
var foo = function() { | |
var y = 20; | |
var bar = function() { | |
var z = 30; | |
console.log(z + y + x); // z is local, y & z are found in the scope chain | |
}(); | |
}() | |
foo(); | |
8)var countUpFromZero = function() { | |
var count = 0; | |
return function() { // return nested child function when countUpFromZero is invoked | |
return ++count; // count is defined up the scope chain, in parent function | |
}; | |
}(); // invoke immediately, return nested function | |
console.log(countUpFromZero()); // logs 1 | |
console.log(countUpFromZero()); // logs 2 | |
console.log(countUpFromZero()); // logs 3 | |
9)Event capturing | |
When you use event capturing | |
| | | |
---------------| |----------------- | |
| element1 | | | | |
| -----------| |----------- | | |
| |element2 \ / | | | |
| ------------------------- | | |
| Event CAPTURING | | |
----------------------------------- | |
the event handler of element1 fires first, the event handler of element2 fires last. | |
Event bubbling | |
When you use event bubbling | |
/ \ | |
---------------| |----------------- | |
| element1 | | | | |
| -----------| |----------- | | |
| |element2 | | | | | |
| ------------------------- | | |
| Event BUBBLING | | |
----------------------------------- | |
the event handler of element2 fires first, the event handler of element1 fires last. | |
Netscape said that the event on element1 takes place first. This is called event capturing. | |
Microsoft maintained that the event on element2 takes precedence. This is called event bubbling. | |
10)Three ants are sitting at the three corners of an equilateral triangle. Each ant starts randomly picks a direction and starts to move along the edge of the triangle. What is the probability that none of the ants collide? | |
11)/* | |
var data=[4,5,6,9,10,14,15,20,21,22,23,24,25,30,31,34] | |
output | |
4-6,9-10,14-15,20-25,30-31,34 | |
*/ | |
var data=[4,5,6,9,10,14,15,20,21,22,23,24,25,30,31,34,36,37,94,95]; | |
var start=data[0]; | |
var temp=1; | |
var a=0; | |
cons(start,temp); | |
function cons(s,t){ | |
if(s+1==data[t]){ | |
s=data[t]; | |
t=t+1; | |
cons(s,t); | |
} | |
else{ | |
print(a,t-1); | |
} | |
} | |
function print(k,t){ | |
display(k,t); | |
t++; | |
a=t; | |
start=data[t]; | |
if(t<data.length){cons(start,t+1)} | |
} | |
function display(k,t){ | |
if(k!=t){ | |
console.log(data[k]+'-'+data[t]);} | |
else{ | |
console.log(data[k]); | |
} | |
} | |
12)Print squares of first n natural numbers without using *, / and - | |
Input: n = 6 | |
Output: 0 1 4 9 16 25 | |
O(n) time | |
solution In Javascript | |
var square =0,prev=0; | |
function printSquares(n){ | |
for(var x=0;x<n;x++){ | |
square = (square+x+prev); | |
//console.log('x'+x);console.log('prev'+prev);console.log('square+x+prev'+square); | |
console.log(square); | |
prev=x; | |
}} | |
printSquares(10); | |
13)Given an array of n+2 element , there are two repeating number , how to find that. | |
n = 5; | |
set {4, 2, 4, 5, 2, 3, 1} | |
output 2 4 | |
solution In Javascript | |
var arr =[4,1,4,5,2,3,2]; | |
var length_arr = arr.length; | |
print_repeating(arr,length_arr) | |
function print_repeating(arr,l){ | |
for(var i=0;i<l;i++){ | |
for(var j=i+1;j<l;j++){ | |
if(arr[i]==arr[j])console.log(arr[i]); | |
}}} | |
Time Complexity: O(n*n) | |
14)Logic gates | |
XOR - > a.!b+!a+b | |
00 0 | |
01 1 | |
10 1 | |
11 0 | |
15)Given a mobile number 10 digit all digits unique,how will you check for number uniqueness , no digit should repeat. | |
Optimization cases. | |
Move all zeroes to end of array | |
Logic Test : | |
You have a basket containing ten apples. You have ten friends, who each desire an apple. You give each of your friends one apple. | |
Now all your friends have one apple each, yet there is an apple remaining in the basket. | |
->each friend has an apple, and one of them has apple+basket. | |
MVC | |
mysql basics | |
What are design patterns in software engineering? | |
What did you learn yesterday/this week? | |
What excites or interests you about coding? | |
Talk about your preferred development environment. (OS, Editor or IDE, Browsers, Tools etc.) | |
Which version control systems are you familiar with? | |
Can you describe your workflow when you create a web page? | |
How would you optimize a websites assets/resources? | |
Traditionally, why has it been better to serve site assets from multiple domains? | |
How many resources will a browser download from a given domain at a time? | |
Do you have any pet projects? What kind? | |
What are some things you like about the developer tools you use? | |
What's a cool thing you've coded recently? What's something you've built that you're proud of? | |
What is Ajax? | |
asynchronous data transfer | |
Bandwidth utilization | |
More interactive | |
Speeder retrieval of data | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment