[Javascript] Funciton Expression
//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的更多相关文章
- [label][翻译][JavaScript Regular Expression]JavaScript Regular Expressions
原文:http://www.javascriptkit.com/javatutors/re.shtml 校验用户的输入是每一个软件开发者的必须要做的事情. 正则表达式与模式 如何在JavaScript ...
- JS正则表达式(JavaScript regular expression)
RegExp直接量和对象的创建 就像字符串和数字一样,程序中每个取值相同的原始类型直接量均表示相同的值,这是显而易见的.程序运行时每次遇到对象直接量(初始化表达式)诸如{}和[]的时候都会创建新对象. ...
- [Javascript] Function Expression Ex, Changing Declarations to Expressions
Inside the Haunted Hickory House file, developers for the Forest of Function Expressions Theme Park ...
- javascript URL实现简易书签
简介 在HTML中,我们可以将js嵌入到script标签中,可以嵌入到行内代码中,也可以嵌入到src(href)中. 后者称作javascript URL.该方式的URL格式固定:javascript ...
- javascript基础语法——表达式
× 目录 [1]原始表达式 [2]复杂表达式 前面的话 一般地,关于javascript基础语法,人们听得比较多的术语是操作符和语句.但是,其实还有一个术语经常使用,却很少被提到,这就是javascr ...
- javascript:void(0) ,设置a链接无效,设置点击a页面不刷新,不跳动
http://www.cnblogs.com/opper/archive/2009/01/12/1373971.html 我想使用过ajax的都常见这样的代码: <a href="ja ...
- Javascript中void操作符
Javascript中void是一个操作符,该操作符指定要计算一个表达式但是不返回值. void操作符用法格式如下:1.javascript:void (expression)2.javascript ...
- JavaScript简易教程(转)
原文:http://www.cnblogs.com/yanhaijing/p/3685304.html 这是我所知道的最完整最简洁的JavaScript基础教程. 这篇文章带你尽快走进JavaScri ...
- javascript知识点记录(1)
javascript一些知识点记录 1.substring,slice,substr的用法 substring 和slice 都有startIndex 和 endIndex(不包括endInex),区 ...
随机推荐
- CodeForces600E Lomsat gelral 线段树合并
从树上启发式合并搜出来的题 然而看着好像线段树合并就能解决??? 那么就用线段树合并解决吧 维护\(max, sum\)表示值域区间中的一个数出现次数的最大值以及所有众数的和即可 复杂度\(O(n \ ...
- bzoj 1658: [Usaco2006 Mar]Water Slides 滑水
题解: 很神奇的做法,把点分成入度大于出度和入度小于出度两种. 然后入度大于出度的点必须走到某个点,所以排序贪心. #include<stdio.h> #include<iostre ...
- GIT(6)----fork和clone的区别,fetch与pull的区别
参考资料: [1].Git学习笔记:fork和clone的区别,fetch与pull的区别 [2].在Github和Git上fork之简单指南
- Matlab 常用绘图指令(二维图形)
使用matlab的时候常常会忘掉一些指令,每次都要重新查找,挺麻烦的,这里收集一些常用的绘图指令,供自己和大家以后方便查找和使用. 1.例子-包含了常用绘图命令 clear clc %%数据准备 x ...
- 【ButterKnife】 安卓程序猿的一大利器
注:近期才看到的这个类库,来自于jakewharton大神的力作,安卓里面的视图注入库 另小弟水平有限,翻译的不好,还请多多指正 首先是地址(托管在github上):http://jakewharto ...
- Send a WhatsApp Message programatically -- Tasker WhatsTasker
Here is My code snippet: Uri mUri = Uri.parse("smsto:+9876543210"); Intent mIntent = new I ...
- __attribute__ ((attribute-list))
http://blog.csdn.net/ithomer/article/details/6566739 构造与析构: #include <stdio.h> #include <st ...
- perf 工具介绍1
https://perf.wiki.kernel.org/index.php/Tutorial http://os.51cto.com/art/201105/265133.htm 在LINUX 源代码 ...
- codeforces 558B Amr and The Large Array-yy
题意:有一个数组.如今要削减它的尺寸.数组中同样元素的个数的最大值为数组的魅力值,要求削减后魅力值不能降低,同一时候要尽可能的把尺寸减到最小 分析:水题,主要是不要想复杂了.还有就是沉下心来做 代码: ...
- Oracle数据库--解决单张表中数据量巨大(大数据、数据量上百万级别,后查询,更新数据等耗时剧增)
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/QQ578473688/article/details/54561397 思路1:采用备份表 备份表中 ...