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
  • 5,880
  • 4
  • 35
  • 53
Bhupendra
  • 910
  • 9
  • 31

0 Answers0