Skip to content

Instantly share code, notes, and snippets.

@intenter
Last active July 1, 2016 09:43
Show Gist options
  • Save intenter/fcd533b81cbab562b46c to your computer and use it in GitHub Desktop.
Save intenter/fcd533b81cbab562b46c to your computer and use it in GitHub Desktop.
js interview questions
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
var alex = new Student('Alex');
alex.haveFun(); //should output 'Alex is having fun'
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
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);
}
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