//This will load the code into the memory no matter
//you call it or not
function diffOfSquares(a,b){
return a*a -b*b;
} //This code will only load into memory when you call it.
var diff = function diffOfSquares(a,b){
return a*a-b*b;
}; diff(9,5); //Call diff function instead of diffOfSquares //So why we still need diffOfSquares, since we don't call it /**
Anonymour Function
*/
var diff = function(a,b){
return a*a-b*b;
}; //You can use console.log(diff); It will print out the
//function instead of the value, so you can check what
//this function refer to. /********************************************/ var greeting = function(){
alert("Thank for fucking!");
}; closeTerminal(greeting); function closeTerminal(message){ ...
message();
....
} //We pass greeting as param to the closeTerminal function
/*
function closeTerminal(greeting){
...
greeting();
...
}
*/
//The out put would be
//"Thank for fucking!" /*********************************************/
//According to difference cases, the greeting message
//may be different.
//For example, newCustomer & oldCustomer, we want to
//take them differently. var greeting;
... //Some code to sets new newCustomer to ture of false
if(newCustomer){
greeting = function(){
alert("Thanks for funcking!");
};
}else{
greeting = function(){
alert("Welcome to be fucked!");
};
} closeTerminal(greeting);
//if newCustomer is true, --> Thanks for funcking!
//if newCustomer is false, --> Welcome to be fucked!

[Javascript] Funciton Expression的更多相关文章

  1. [label][翻译][JavaScript Regular Expression]JavaScript Regular Expressions

    原文:http://www.javascriptkit.com/javatutors/re.shtml 校验用户的输入是每一个软件开发者的必须要做的事情. 正则表达式与模式 如何在JavaScript ...

  2. JS正则表达式(JavaScript regular expression)

    RegExp直接量和对象的创建 就像字符串和数字一样,程序中每个取值相同的原始类型直接量均表示相同的值,这是显而易见的.程序运行时每次遇到对象直接量(初始化表达式)诸如{}和[]的时候都会创建新对象. ...

  3. [Javascript] Function Expression Ex, Changing Declarations to Expressions

    Inside the Haunted Hickory House file, developers for the Forest of Function Expressions Theme Park ...

  4. javascript URL实现简易书签

    简介 在HTML中,我们可以将js嵌入到script标签中,可以嵌入到行内代码中,也可以嵌入到src(href)中. 后者称作javascript URL.该方式的URL格式固定:javascript ...

  5. javascript基础语法——表达式

    × 目录 [1]原始表达式 [2]复杂表达式 前面的话 一般地,关于javascript基础语法,人们听得比较多的术语是操作符和语句.但是,其实还有一个术语经常使用,却很少被提到,这就是javascr ...

  6. javascript:void(0) ,设置a链接无效,设置点击a页面不刷新,不跳动

    http://www.cnblogs.com/opper/archive/2009/01/12/1373971.html 我想使用过ajax的都常见这样的代码: <a href="ja ...

  7. Javascript中void操作符

    Javascript中void是一个操作符,该操作符指定要计算一个表达式但是不返回值. void操作符用法格式如下:1.javascript:void (expression)2.javascript ...

  8. JavaScript简易教程(转)

    原文:http://www.cnblogs.com/yanhaijing/p/3685304.html 这是我所知道的最完整最简洁的JavaScript基础教程. 这篇文章带你尽快走进JavaScri ...

  9. javascript知识点记录(1)

    javascript一些知识点记录 1.substring,slice,substr的用法 substring 和slice 都有startIndex 和 endIndex(不包括endInex),区 ...

随机推荐

  1. Makefile-fPIC,C++静态库与动态库

    在计算机领域中,地址无关代码 (英文: position-independent code,缩写为PIC),又称地址无关可执行文件 (英文: position-independent executab ...

  2. 洛谷P2657 Loj10165 SCOI2009 windy数

    题目描述 windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为windy数. windy想知道, 在A和B之间,包括A和B,总共有多少个windy数? 输入输出格式 输 ...

  3. mysql-5.7.10产生的日志时间与系统时间不一致

    问题描述: 使用安装的mysql workbench登录mysql后,选择server log 进行日志查看的时候,发现产生日志的时间和当期的系统时间不一致:如下图: 查看mysql系统的当期时间显示 ...

  4. paypal对接

    paypal支付接口准备工作 首先去申请一个paypal账号,https://www.paypal.com/. 申请完毕并登录,进入https://developer.paypal.com/devel ...

  5. js面向对象写页面

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. PostgreSQL教程收集(中文文档/命令行工具/常用命令)

    http://www.postgres.cn/docs/9.6/index.html(中文文档) https://www.postgresql.org/docs/10/static/auth-meth ...

  7. cocos2d-x3.0 Slider

    .h #include "cocos2d.h" #include "cocos-ext.h" #include "ui/CocosGUI.h" ...

  8. xcode4.3.2 arc模式下导入非arc的文件 转

    在arc模式下,我们经常会用到非arc的类库,此时我们可以在Compile Sources下对该文件进行编辑加入 -fno-objc-arc   如图中所示,就可以使用非arc的类库了   转:htt ...

  9. 1. python 字符串简介与常用函数

    1. python中的字符串简介与常用函数 在python中,字符串变成了一个强大的处理工具集,他是不可变的,也就是说字符串包含字符与字符的顺序,他不可以原处修改 字符串是我们后面需要学习的稍大一点的 ...

  10. arcgis python添加几何属性

    import arcpy import numpy import math def AddGeometryAttributes(fc, geomProperties, lUnit, aUnit, cs ...