0

I was asked this question in an Interview for JS

function display() {
  var a = b = 10;
}
display();
console.log('b', typeof b === 'undefined');
console.log('a', typeof a === 'undefined');

My ans was : b false a false but according to the interviewer It should be b false a true

I didn't fully understood him . What should be the correct explanation/answer will be?

VLAZ
  • 26,331
  • 9
  • 49
  • 67
shivam
  • 11
  • 4

1 Answers1

-2

If you write like inside function then only answer will be false false.

function display() 
{
var a = b = 10;
console.log('b',  b === 'undefined');
console.log('a',  a === 'undefined');
}
display();