Teil von SELFHTML Forum Teil von SELFHTML Forumsarchiv Teil von 2008 Teil von Juni

SELFHTML Forumsarchiv
unterschied foo = function() und foo: function()

Informationsseite
  1. Seite (JAVASCRIPT) unterschied foo = function() und foo: function() von royal, 30. 06. 2008, 15:13
nach unten

unterschied foo = function() und foo: function()

Die folgende Nachricht zum Thema stammt von: royal, 30. 06. 2008, 15:13

hallo zusammen,

kann mir jemand beim prototype framework den unterschied zwischen

foo = function()
{
}

und

foo: function()
{
}

erläutert ? also doppelpunkt statt =


gruß
royal

nach obennach unten

unterschied foo = function() und foo: function()

Die folgende Nachricht zum Thema stammt von: Cheatah, 30. 06. 2008, 17:21

Hi,

»» kann mir jemand beim prototype framework den unterschied zwischen
»» foo = function()
»» und
»» foo: function()
»» erläutert ? also doppelpunkt statt =

nicht beim Prototype-Framework, aber bei JavaScript :-)

Das "=" ist eine einfache Wertzuweisung. Der Variablen foo wird eine Funktion zugewiesen; anschließend ist "foo()" anwendbar.

Der ":" wird vermutlich innerhalb der Objekt-Kurzschreibweise verwendet:

var xyz = {
    foo: function() { ... }
};


Und genau das ist es dann auch: Objekt-Kurzschreibweise. Es ist identisch mit

var xyz = new Object();
xyz.foo = function() { ... }


Anschließend ist "xyz.foo()" anwendbar.

Cheatah

--
X-Self-Code: sh:( fo:} ch:~ rl:° br:> n4:& ie:% mo:) va:) de:] zu:) fl:{ ss:) ls:~ js:|
X-Self-Code-Url: http://emmanuel.dammerer.at/selfcode.html
X-Will-Answer-Email: No
X-Please-Search-Archive-First: Absolutely Yes

nach oben
Teil von SELFHTML Forum Teil von SELFHTML Forumsarchiv Teil von 2008 Teil von Juni

© 1998-2006 Seite Impressum, Software: Classic Forum