//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. windows svn 客户端连不上linux svn server

    采坑记录:linux服务器上svn://127.0.0.1可以正常使用,windows客户端远程连接不上,说明是端口号的问题. linux正常配置了iptables开启了3690端口,连接不上. 干脆 ...

  2. Failed to resolve: com.android.support:design:25.4.0

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 错误:(27, 13) Failed to resolve: com.android.s ...

  3. 【枚举】AtCoder Regular Contest 095 C - Symmetric Grid

    题意:给你一个H*W的字符矩阵,一次操作可以任意将两行或者两列交换.问你是否能通过任意多次操作,使得其变为对称矩阵.对称的含义是:对于任何格子A(i,j),其都等于A(H-i+1,W-j+1). 显然 ...

  4. java多线程技术之八(锁机制)

    Lock是java.util.concurrent.locks包下的接口,Lock 实现提供了比使用synchronized 方法和语句可获得的更广泛的锁定操作,它能以更优雅的方式处理线程同步问题,我 ...

  5. 【洛谷】4180:【模板】严格次小生成树[BJWC2010]【链剖】【线段树维护最大、严格次大值】

    P4180 [模板]严格次小生成树[BJWC2010] 题目描述 小C最近学了很多最小生成树的算法,Prim算法.Kurskal算法.消圈算法等等.正当小C洋洋得意之时,小P又来泼小C冷水了.小P说, ...

  6. 3、Redis中对String类型的操作命令

    写在前面的话:读书破万卷,编码如有神 -------------------------------------------------------------------- ------------ ...

  7. Codeforces Round #298 (Div. 2) E. Berland Local Positioning System 构造

    E. Berland Local Positioning System Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.c ...

  8. redis学习之一 - linux下安装配置

    Content 0.序 1.如何安装? 2.配置参数及其意义 3.设为linux服务 0.序 本文主要是记录Redis在 Centos下的安装配置 .文中如无特别说明.表示redis-3.2.10代码 ...

  9. LogStash日志分析系统

    简介 通常日志管理是逐渐崩溃的——当日志对于人们最重要的时候,也就是出现问题的时候,这个渐进的过程就开始了.日志管理一般会经历一下3个阶段: 初级管理员将通过一些传统工具(如cat.tail.sed. ...

  10. Java_模拟comet的实现

    本文没有使用任何comet服务器, 只是利用tomcat模拟实现了一下comet, 不是真正的comet哦,因为不会有这样的应用场景, 只是模拟实现, 仅供参考. 一. 需求. 实现将服务端的时间推送 ...