90% of Javascript Candidate Failed to answer these Snippets

Q1. Guess the output:

var marvel = ['batman', 'thanos', 'superman'];
a[100] = 'catwomen';
console.log(a.length);

Think hard don’t jump into output

Output: 101

Q2. Guess Output:

sumof(40, 60);
diffof(40, 60);
function sum(x, y) {
return x + y;
}

let diff = function (x, y) {
return x - y;
};

Think hard don’t jump into output

Output:100, ReferenceError

Q3. Guess Output:

var count = 1;
var fun1 = function () {
console.log(count);
};

var fun2 = function () {
var count = 2;
fun1();
};

fun2();

Think hard don’t jump into output

Output: 1

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vineet Mishra

Vineet Mishra

Full Stack Developer at CCR Tech, I write about Mobile/Web Development and Deployment, and Interview Q & A