每天CookBook之JavaScript-031
- 函数的定义
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>031</title>
</head>
<body>
</body>
<script type="text/javascript">
(function () {
console.log(a);
var a;
})();
(function () {
console.log(a);
var a = 1;
})();
(function () {
console.log(test());
function test () {
return 'hello';
}
})();
(function () {
try {
console.log(test());
} catch(e) {
console.log(e);
}
var test = function(){
return 'hello';
}
})();
</script>
</html>