Function() 생성자는 임의의 수의 문자열 인수를 예상합니다. 마지막 인수는 함수의 본문이며 세미콜론으로 서로 구분된 임의의 JavaScript 문을 포함할 수 있습니다.
예시
다음 코드를 실행하여 새로운 함수 생성자로 함수를 호출할 수 있습니다. −
<html>
<head>
<script>
var func = new Function("x", "y", "return x*y;");
function multiplyFunction(){
var result;
result = func(15,35);
document.write ( result );
}
</script>
</head>
<body>
<p>Click the following button to call the function</p>
<form>
<input type = "button" onclick = "multiplyFunction()" value = "Call Function">
</form>
</body>
</html>