08函数的其他的定义方式.html
- 08函数的其他的定义方式.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>08函数的其他的定义方式</title>
<script>
/**
* 命名函数:函数如果有名字,就是命名函数
*
* 匿名函数:函数如果没有名字,就是匿名函数
*
* 函数的另一种定义方式
* 函数表达式:
* 把一个函数给一个变量,此时形成了函数表达式
* var 变量 = 匿名函数;
* 例子:
* var f1=function (){
*
* };
* 如果是函数表达式那么此时前面的变量中存储的就是一个函数,而这个变量就相当于 是一个函数,就可以直接加
* 小括号调用了
* f1();
*
* f1即是函数代码块加 (); 就能调用函数
*
* 注意:
* 函数表达式后面,赋值结束后,要加分号
*
*
*
*
* 函数定义:
* 1.函数声明--函数定义
* function 函数名(){
* 函数体
* }
*/
// (function () {
// console.log("月色真美!");
// })();//月色真美!
//函数的自调用,没有名字,调用---声明的同时,直接调用
//一次性的----
(function(){console.log("月色真美2");})();
var f1=function(){console.log("月色真美2");};
f1();
// //命名函数
// function f1(){
// console.log("哈哈,您又变帅了");
// }
// f1();//函数调用
// //如果一个函数能够调用:函数的代码();
// // 匿名函数
// //函数表达式
// var f2=function (){
// console.log("真的真的?");
// };
// //匿名函数不能直接调用
// f2();
//
//
// var f4=function(){
// console.log("我是一个函数");
// };
// f4();
// //函数声明(如果函数名重名会覆盖,)
function f1() {
console.log("妹妹教师好帅");
}
f1();//姐姐教师好帅(函数重名就执行后一个,后面一个覆盖前面一个)
function f1() {
console.log("姐姐教师好帅");
}
f1();//姐姐教师好帅
// // 函数表达式
var f2=function (){
console.log("助教姐姐好帅");
};
f2();//助教姐姐好帅
f2=function (){
console.log("小助教好帅");
};
f2();//小助教好帅
// var num=10;
// console.log(num);//10
// num=100;
// console.log(num);//100
</script>
</head>
<body>
</body>
</html>

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
-
上一篇
git 提交出现error: Your local changes to the following files would be over...
在提交代码时,直接在master分支push了,而原来的testdemo分支没有merge,这样提交过后会报错 error: Your local changes to the following files would be overwritten by checkout: app/Http/Controllers/UsersController.php Please commit your changes or stash them before you switch branches. Aborting 提示的是当前改变文件会被覆盖,出现这个问题,我们需要让master回退到上一个版本 git reset --hard 版本号 此时,在使用git merge testdemo分支即可。 git merge testdemo 合并完testdemo分支后,我们再次push即可。 git push
-
下一篇
【译Py】Dash用户指南01-02_安装与应用布局
封面 【译Py】Python交互式数据分析报告框架~Dash介绍 【译Py】Dash用户指南01-02_安装与应用布局【译Py】Dash用户指南03_交互性简介【译Py】Dash用户指南04_交互式数据图【译Py】Dash用户指南05_使用State进行回调 1. 安装 Dash需要安装以下几个库才能正常使用,这些库仍在不断更新,请注意及时升级。 Dash支持Python2与Python3。 pip install dash==0.25.0 # Dash核心后端 pip install dash-renderer==0.13.2 # Dash前端 pip install dash-html-components==0.11.0 # HTML组件 pip install dash-core-components==0.27.1 # Dash核心组件 pip install plotly --upgrade # Plotly图形库 译注:通过以下链接查看Dash及其支持库的最新版本。 dash dash-renderer dash-html-components dash-core-com...
相关文章
文章评论
共有0条评论来说两句吧...