function 함수명(){
//자바스크립트 코드문
}
function abc(d, e){
return d + e;
}
var abc function(d, e){
return d, e;
}
abc(d,e);
function abc(d, e, f){
//함수 본문
}
//함수 리터럴 : 'function(a, b){...}' 부분
var other = function(a, b){
//함수 본문
}
//other : 함수 리터럴에 의해 정의되어 할당된 변수(함수 표현식)
abc(other, a, b);
//ex1)
var square = new Function("x", "return x * x");
square(5);
//숫자 25 출력
//ex2)
var functionName = new Function (x, y, functionBody);
functionName(a, b);
// 호출시에 Function 함수 객체에서 두 인수 a, b를 처리하게 됨
function fstFncExample () {
var a = 1;
function secondFncExample () {
return a * 2;
}
return secondFncExample();
}
function MainFnc {
var arg;
// 콜백함수를 익명으로 전달하는 구조
LibraryFunction(arg, function(result){
// result를 사용한 연산
});
}
페이지 로드시 호출될 콜백 함수
window.onload = function() {
alert('This is the callback function.');
}
$(document).ready(function(){
//자바스크립트 코드문
});
(function (name) {
console.log('This is the immediate function --> ' + name);
})('foo');