<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
/*
1.js中所有的函数对象 , 都是被 Function构造函数创建
*/
//1. new Function()
//参数 (1)前面所有的参数都是函数形参 (2)最后一个参数是函数体代码
//返回值 : 函数对象
var fn = new Function('a','b','console.log("6666");return a+b;');
var res = fn(10,20);
console.log(res);
//2.js基础函数两种声明方式
//这两种声明方式底层都是调用构造函数 new Function()
//2.1 函数式声明
function fn1(a,b){
return a+b;
};
//2.2 表达式声明
var fn2 = function(){
};
</script>
</body>
</html>
04-Function构造函数
最新推荐文章于 2019-10-13 15:23:32 发布