Re: [情報] Java 即將加入 Closure
※ 引述《qazxsw99.bbs@ptt.cc (qazxsw99)》之銘言:
: 而我想問一下,以下是Closure的基本應用嗎?
: 像javascript可以把function當作參數傳送
: : ex:
: function sayhello() {
: alert('hello');
: }
: var f = sayhello
: f(); //此時同等於呼叫sayhello function
: 這只是最基本的應用,我個人認為啦...
function Robot() {
var createTime = new Date();
this.getAge = function() {
var now = new Date();
var age = now - createTime;
return age;
}
}
var robbie = new Robot();
window.onload = function() {
alert(robbie.getAge());
}
摘自Ajax in action 附錄 B。。。
--
\,`/ / 。。。 嗨!
_).. `_
( __ -\
'`.
( \>_-_,
_||_ ~-/ http://caterpillar.onlyfun.net/
--
※ Origin: 臺大電機 Maxwell 站 ◆ From: 218-166-217-253.dynamic.hinet.net
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 8 之 16 篇):