The following keyword references the arguments that the constructor function

The following keyword references the arguments that

This preview shows page 213 - 216 out of 334 pages.

The following keyword references the arguments that the constructor function receives: this You can think of the this keyword as meaning this object . Example of Using a Constructor Function To create a rectangle object, the following example uses the new operator to call the constructor function: var joe = new Rectangle(3,4) var sally = new Rectangle(5,3); This code creates the following rectangle objects:
Image of page 213
Siebel eScript Language Reference Version 8.1, Rev. A Methods Reference Custom Methods 214 Joe, with a width of 3 and a height of 4 Sally, with a width of 5 and a height of 3 This example creates a Rectangle class and two instances of this class. A constructor function creates objects that belong to the same class. Every object that a constructor function creates is an instance of that class. Instances of a class share the same properties, although a particular instance of the class can possess more unique properties. For example, adding the following code to the example adds a motto property to the joe rectangle. The sally rectangle does not include a motto property: joe.motto = "Be prepared!"; How a Function Is Assigned to an Object An object can contain a function and variables. A function assigned to an object is a method of that object. A method uses the this operator to reference a method variable. The following example is a method that computes the area of a rectangle: function rectangle_area() { return this.width * this.height; } Because no arguments are passed to it, this function is meaningless unless an object calls it. This object provides values for this.width and this.height. The following code assigns a method to an object: joe.area = rectangle_area; The function now uses the values for height and width that were defined when you created the joe rectangle object. To assign a method in a constructor function, you can use the this keyword. The following example creates an object class named Rectangle that includes the rectangle_area method as a property: function rectangle_area() { return this.width * this.height; } function Rectangle(width, height) { this.width = width; this.height = height; this.area = rectangle_area; } The method is available to any instance of the class. The following example sets the value of area1 to 12 and the value of area2 to 15:
Image of page 214
Methods Reference Custom Methods Siebel eScript Language Reference Version 8.1, Rev. A 215 var joe = Rectangle(3,4); var sally = Rectangle(5,3); var area1 = joe.area(); var area2 = sally.area(); About Object Prototypes An object prototype lets you specify a set of default values for an object. If Siebel eScript accesses an object property that is not assigned a value, then it consults the prototype. If this property exists in the prototype, and if this property contains a value, then Siebel eScript uses that value for the object property.
Image of page 215
Image of page 216

You've reached the end of your free preview.

Want to read all 334 pages?

  • Summer '16
  • Oracle
  • Type system, Siebel, Siebel eScript

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors