1.普通函数定义的两种写法

function hello(){
console.log("hello!");
} var hello = function(){
console.log("hello!");
}

2.函数自执行,快速初始化变量(两种写法hello变量值为15)

#函数自执行
var hello = function(num){
return 3 * num;
}(5); #普通写法
var hello = 5;
hello = 3 * hello;

3.函数预执行

(function(){
console.log('Hello ');
})();

4.闭包

function say(name){
var info = 'Hello ' + name;
return function(){
console.log(info);
}
}
var s= say('bret');
s();

  

最新文章

  1. java面试知识(来自牛客网)
  2. awk的涂鸦
  3. 每天一个linux命令(7):mv命令
  4. java.sql.SQLException: null, message from server: “Host ‘xxx’ is not allowed to connect
  5. oGrid 介绍如何从 server 取的资料
  6. Javascript 笔记与总结(2-17)事件委托
  7. linux 相关系列安装
  8. vim配置php开发环境
  9. MySQL存储过程之事务管理
  10. WPF拖到、移动控件
  11. 输出内容(document.write)四种写法
  12. Rabbitmq中rabbitmqctl的常用命令
  13. Redis教程03——Redis 发布/订阅(Pub/Sub)
  14. IT项目经理
  15. java如何把char型数据转换成int型数据(转)
  16. HDU 5558 后缀数组+二分
  17. HDFS概述(4)————HDFS权限
  18. 目标检测算法之Faster R-CNN算法详解
  19. 浏览器JS报错Uncaught RangeError Maximum call stack size exceeded
  20. C# SetParent将其他程序嵌入自己的程序

热门文章

  1. 小程序(Wepy)--生成海报图片
  2. BZOJ 1396 识别子串 (后缀自动机+线段树)
  3. nfs+inotify
  4. 集成spring boot + mysql + docker实战
  5. 常用js方法封装
  6. 【转载】linux下的usb抓包方法
  7. Android知识点总结
  8. 手写一个节点大小平衡树(SBT)模板,留着用
  9. NHibernate3剖析:Query篇之NHibernate.Linq增强查询
  10. java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start com