Last active
July 1, 2016 09:43
-
-
Save intenter/fcd533b81cbab562b46c to your computer and use it in GitHub Desktop.
js interview questions
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
var counter = require('counter.js'); | |
counter.increment(); | |
console.log(counter.value); //prints 1 | |
var counter2 = require('counter.js'); | |
counter2.increment(); | |
console.log(counter2.value); //prints 2 |
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
var alex = new Student('Alex'); | |
alex.haveFun(); //should output 'Alex is having fun' |
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
function hasDups(arr){ | |
<....> | |
} | |
a1 = [[1, 2, 3], [4, 5, 6], [7, 1, 8]]; | |
a2 = [[1,2,3],[4,5,6,7], [8,9,10,11,12], [13,14,15]] | |
hasDups(a1); //true | |
hasDups(a2); //false | |
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
try { | |
loadData('/api/entities', function (err, data){ | |
if (!err){ | |
console.log('Error fetching data: ' + err); | |
} | |
JSON.parse(data); | |
}); | |
} catch (ex){ | |
console.log('Error parsing data: ' + ex); | |
} |
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
var defaultOptions = {a: 10; b:20}; | |
var options = {a: 15}; | |
var full = withDefault(options, defaultOptions); | |
console.log(full.a); //15 | |
console.log(full.b) //20 | |
console.log(options.b) // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment