<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>function on adolsai's echo</title><link>https://adolsai.com/tag/function/</link><description>Recent content in function on adolsai's echo</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Wed, 19 Mar 2014 08:52:18 +0800</lastBuildDate><atom:link href="https://adolsai.com/tag/function/index.xml" rel="self" type="application/rss+xml"/><item><title>javascript learning notes——function</title><link>https://adolsai.com/archives/43.html</link><pubDate>Wed, 12 Mar 2014 00:13:00 +0800</pubDate><guid>https://adolsai.com/archives/43.html</guid><description>&lt;p&gt;&lt;strong&gt;函数&lt;/strong&gt;：一次定义，多次执行。js的函数调用还有一个特性，每次调用都会拥有另一个值——本次调用的this值（上下文/context）。函数可以作为对象的一个属性，称为对象的方法。当通过对象调用函数时，该对象就是此次调用的上下文。&lt;/p&gt;&#10;&lt;pre&gt;&lt;code&gt;//在定义的时候递归&#10;var f = function fact(x) {if (x&amp;lt;=1) return 1; else return x*fact(x-1);};&#10;//作为参数传递&#10;data.sort(function(a,b){return a-b;});&#10;//定义后立即使用&#10;var tensquared = (function(x){return x*x}(10));&#10;&lt;/code&gt;&lt;/pre&gt;</description></item></channel></rss>