JavaScript - Create New Object (Function) Using an object literal? -
I have defined a function with two javascript: Inside another function I am making a new example of There is no way to create an event like the following example: I think this signaling looks better, it sounds more concise and easy to read. =========================== Updates ======== ======================== Based on Tim's reply it is done in the following manner: < Pre> I have the following questions. Let me assume that I have 2 works both with exact properties and Constructor logic: And I have a container that keeps some kind of: If I add a single function using that method then how will it actually be? There are a lot of options, but keeping it simple .. you just do this : You do not need to declare "type", but you can do this: size and
url :
function IconInfo () {this.size = size; This.url = url; }
IconInfo and set the property in this way:
< Code> function SomeFunction () {Var icon = New IconInfo (); Icon.size = 64; Icon.url = "http://somesite.com/image1.png"; }
var icon = new iconInfo ({Size: 64, url: "Http : //somesite.com/image1.png "});
var icon = {size: 64, url: "http://somesite.com/image1.png"};
Func1 (x) {this.x = x; } Func2 (x) {this.x = x; }
function container () {this.f = null; }
... var container = new container (); Container.x = New F {// F.Funka 1 or Funk 2? X: 10; }
var icon = {size: 64, url: "http://somesite.com/image1.png"};
function IconInfo (size, url) This.size = Shape; This.url = url; ); Var icon = New icon Infos (2, "www.google.com");
Comments
Post a Comment