The two ways to declare a java script function:
var functionOne = function() {
// Some code
};
function functionTwo() {
// Some code
}
The difference is that
functionTwo
is defined at parse-time for a script block, whereas functionOne
is defined at run-time. For example:<script>
// Error
functionOne();
var functionOne = function() {
}
</script>
<script>
// No error
functionTwo();
function functionTwo() {
}
</script>
No comments:
Post a Comment