M Sheik 的个人资料udooz!照片日志列表 工具 帮助

日志


5月15日

JavaScript – Platform for Web 2.0

I was excluded JavaScript in the "Web 2.0 basic things" intentionally, because JavaScript is the only choice for every web pages. But most of us know and/or use half the feature of JavaScript. JavaScript has more than these.  Lot of frameworks which target Web 2.0 and applications utilize these smart features. I would like to share some of these features which make JavaScript as a platform for Web 2.0 applications.

If you know these, please have a look and share your knowledge.

Before getting into these, keep the following statement in your mind about JavaScript:

"Anything can be defined within the context of anything and assigned it to anything".

Confused?

Let's take an example, you can define a class from a function and enumerate its properties as array elements. And, you can treat an array as a object, function as data, etc. The following sections briefs about this.

Lamda Functions

Lamda functions are unnamed functions which can be assigned to a variable like assigning an expression. This is more or less similar to functional programming style. See the following example:

var square = function(x){return x*x;}    

alert(square(2)); // returns 2 * 2 = 4  

Code Snippet 1  

The square is actually a variable on which the function reference with the above signature has been assigned.

What is the difference between normal named functions and lamda functions?

Let us see the below code snippets:

var square = function(x){return x*x;}    

function twoSquare(square)

{

    return square * 2;

 

alert(twoSquare(square(3))); // returns 9 * 2 = 18

Code Snippet 2

In the above example, the lamda function "square" is passed as argument to "twoSquare" function as function reference. See the body of "twoSquare". It treats the function "square" as a variable.

Also, you can assign or treat lamda function to object property and array element. The developers of "C" family can enjoy this feature.

The lamda function simulates the C++ or C# style class declaration when creating a class. See the Code Snippet 3.

function Customer(title, firstName)

{

    this.title = title;

    this.firstName = firstName;

    this.getName = function(){return this.title + " " + this.firstName.toUpperCase();}

}

 

var amid = new Customer("Mr","Amid");

alert(amid.getName()); // returns Mr AMID

 Code Snippet 3

 In code snippet 3, a class Customer has been defined. In this getName is a lamda function. Remember, getName is variable to the function reference.

Let us see other features in succeeding articles.

评论 (3)

请稍候...
很抱歉,您输入的评论太长。请缩短您的评论。
您没有输入任何内容,请重试。
很抱歉,我们当前无法添加您的评论。请稍后重试。
若要添加评论,需要您的家长授予您相应权限。请求权限
您的家长禁用了评论功能。
很抱歉,我们当前无法删除您的评论。请稍后重试。
您已超过了一天之内允许提供的评论数上限。请在 24 小时后重试。
因为我们的系统表明您可能在向其他用户提供垃圾评论,您的帐户已禁用了评论功能。如果您认为我们错误地禁用了您的帐户,请联系 Windows Live 支持部门
完成下面的安全检查,您提供评论的过程才能完成。
您在安全检查中键入的字符必须与图片或音频中的字符一致。

若要添加评论,请使用您的 Windows Live ID 登录(如果您使用过 Hotmail、Messenger 或 Xbox LIVE,您就拥有 Windows Live ID)。登录


还没有 Windows Live ID 吗?请注册

没有名字发表:
http://www.nizikaikun.com/
http://www.ms-online.co.jp/eshop/ona_hole.php
http://www.ms-shop.co.jp/shop/goods/goods.asp?category=5308
http://www.ms-online.co.jp/eshop/goods/vibe.php
http://www.ms-online.co.jp/eshop/goods/costume.php
http://www.chojudo.ne.jp/
http://www.open-japan.com/
http://www.open-japan.com/ideabox/index.php?category=beauty#top
http://www.open-japan.com/ideabox/index.php?category=dress#top
http://www.eic-av.com/
http://www.nicolas-dogs.com/
http://www.aqua01.net/
http://www.kabudayo.com/
http://www.fxf-business.com/
http://kaketayo.sakura.ne.jp/
http://www.11cash.net/
http://www.saimu0.jp/
http://telink.jp/
http://www.complete-watch.com/
http://www.tokei-biho.com/
http://www.e-msqs.com/
http://www.hattori-tax.jp/
http://www.webtravel.co.jp/
http://www.webtravel.co.jp/usa/index.html
http://www.webtravel.co.jp/asia/chaina/index.html
http://www.webtravel.co.jp/aironly/index.htm
http://www.webtravel.co.jp/hotel/oahu/halekurani.htm
http://www.colorcontact1.com/
http://www.trivy-system.com/Sinyou.htm
http://www.effect-japan.com/
http://www.myhome-rd.co.jp/
http://my-trunk.jp/
http://www.kabu-net.com/
http://www.trivy-system.com/Kekkon.htm
http://www.kabarai-seikyu.com/
http://www.sigmac.jp/
http://www.e-fil.co.jp/
http://www.sample-net.com/
http://www.clasic.jp/goods/nudefitcoat.htm
http://www.clasic.jp/goods/tradcasey.htm

http://www.clasic.jp/
http://www.bit-of-sound.com/
http://www.hyousatu.com/
http://www.a-world.co.jp/
http://www.a-toy.ne.jp/
http://www.blyjapon.com/
http://adultshop.co.jp/omocha.html
http://adultshop.co.jp/adultshop.html
http://adultshop.co.jp/andropenis.html
http://adultshop.co.jp/andropenis2.html
http://adultshop.co.jp/onahole.html
http://adultshop.co.jp/houkei.html
http://adultshop.co.jp/anal.html
http://adultshop.co.jp/enemagra.html
http://adultshop.co.jp/denma.html
http://adultshop.co.jp/dutch.html
http://furniture.michiookamoto.com/
http://www.achelabo.jp/
http://www.takumi-pg.com/
http://www.omochacha.com/
http://www.av-one.jp/zero/top.html
http://umanity.jp/
http://www.bse.jp/
http://www.claudia.co.jp/tuhan/goods/beauty/yomogi_hot_sheet/index.html
http://www.claudia.co.jp/tuhan/goods/beauty/ekusute_kit/index.html
http://yumemirai.ne.jp/
http://ftb-rmt.jp/
http://ftb-rmt.jp/atlantica/
http://ftb-rmt.jp/chusen/
http://ftb-rmt.jp/arad/
http://ftb-rmt.jp/tw/
http://ftb-rmt.jp/redstone/
http://ftb-rmt.jp/nobunaga/
http://ftb-rmt.jp/ff11/
http://ftb-rmt.jp/lh/
http://ftb-rmt.jp/lineage2/
http://asaka.century21web.jp
http://niiza.century21web.jp
http://wako.century21web.jp
http://www.21tokiwa.co.jp
http://www.century21web.jp
http://shiki.century21web.jp
http://www.trivy-system.com/Sinyou.htm
http://www.trivy-system.com/Kekkon.htm
1 月 5 日
匿名 的图片
udooz 发表:
I'm sheik from Chennai.
Silverlight is major step forward in Web 2.0 from Microsoft.
5 月 18 日
Arvindh发表:
acutally wht is sliverlight is that anyway related to web 2.0 could you please let me know?.
5 月 18 日

引用通告

此日志的引用通告 URL 是:
http://udooz.spaces.live.com/blog/cns!1EA86C1FB1C134B8!190.trak
引用此项的网络日志