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
  • 6,518
  • 4
  • 40
  • 59
Bhupendra
  • 1,032
  • 12
  • 34

0 Answers0