//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. 排序算法之冒泡排序Java实现

    排序算法之冒泡排序 舞蹈演示排序: 冒泡排序: http://t.cn/hrf58M 希尔排序:http://t.cn/hrosvb  选择排序:http://t.cn/hros6e  插入排序:ht ...

  2. C++11中的raw string literals

    作为一名C++书看得少得可怜的新手,我一直没有勇气去系统地学习一下C++ 11添加的新特性.不过,平日里逛论坛,阅读大犇们的博客,倒是了解了一些.比如,这个帖子: 如何绕过g++ 4.8.1那个不能在 ...

  3. .vs目录有什么用?

    写这篇博文的目的就是方便后来者能够在百度里轻松搜到. 反正我找了半天没找到关于.vs目录的介绍,最后还是在同事的帮助下才找到的. 参考地址:https://developercommunity.vis ...

  4. redis的搜索组件 redis-search4j

    redis-search4j是一款基于redis的搜索组件. 特点 1.基于redis,性能高效 2.实时更新索引 3.支持Suggest前缀.拼音查找(AutoComplete功能) 4.支持单个或 ...

  5. Python threads synchronization: Locks, RLocks, Semaphores, Conditions, Events and Queues(Forwarding)

    This article describes the Python threading synchronization mechanisms in details. We are going to s ...

  6. Codeforces Round #309 (Div. 2) C. Kyoya and Colored Balls

    Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are ...

  7. java对mongodb的and, in, or 经常使用操作

    DBCollection dbcon = null; DBObject query = new BasicDBObject(); BasicDBList values = new BasicDBLis ...

  8. hibernate一级缓存,二级缓存和查询缓存

    一级缓存 (必然存在)  session里共享缓存,伴随session的生命周期存在和消亡:   1. load查询实体支持一级缓存 2. get查询实体对象也支持 3. save保存的实体对象会缓存 ...

  9. .NET:CLR via C# The Interlocked Anything Pattern

    Many people look at the Interlocked methods and wonder why Microsoft doesn't create a richer set of ...

  10. 理解与学习linux 文件系统的目录结构

    1. linux文件系统的结构 linux文件系统是以一种树形结构存在,Linux的文件系统的入口就是/,所有的目录.文件.设备都在/之下,/就是Linux文件系统的组织者,也是最上级的领导者. 2. ...