Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created March 24, 2014 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennadel/9751103 to your computer and use it in GitHub Desktop.
Save bennadel/9751103 to your computer and use it in GitHub Desktop.
Calling Sub-Function in Javascript Different in Safari
// This will NOT work in safari.
function Foo2(){
alert("In Foo2 Method");
(
function Bar2(){
alert("In Bar2 Method");
}
)();
}
// Call the Foo2 method for testing.
Foo2();
// This will work in Safari.
function Foo(){
alert("In Foo Method");
(
function (){
alert("In Bar Method");
}
)();
}
Foo();
// This will work in Safari.
function Foo(){
alert("In Foo Method");
function Bar(){
alert("In Bar Method");
}
Bar();
}
Foo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment