1

I was just trying function hoisting in js , I have a doubt in below code

// Case 1
var foo = function() {
    return 3;
}

// Case 2
function foo() {
    return 2;    
}
alert(foo());

Why case1 gets preference over case 2 always? case 2 never overrides case 1 , why?

jayelm
  • 7,236
  • 5
  • 43
  • 61
Bhupendra
  • 1,196
  • 16
  • 39

0 Answers0