JavaScript 1.2는 함수를 정의하는 또 다른 새로운 방법인 함수 리터럴의 개념을 도입했습니다. 함수 리터럴은 이름 없는 함수를 정의하는 표현식입니다.
예시
JavaScript에서 기능 리터럴을 구현하기 위해 다음 예를 시도할 수 있습니다.
라이브 데모
<html>
<head>
<script>
<!--
var func = function(x,y){ return x*y };
function secondFunction(){
var result;
result = func(10,20);
document.write ( result );
}
//-->
</script>
</head>
<body>
<p>Click the following button to call the function</p>
<form>
<input type="button" onclick="secondFunction()" value="Call Function">
</form>
<p>Use different parameters inside the function and then try...</p>
</body>
</html>