Javascript-Referência JavaScript - Letras D a E
[Arquivo anterior (letras A a C)]      [Arquivo posterior (letras F a G)]

date

object. lets you work with dates and times.

syntax

to create a date object:

1. dateobjectname = new date()
2. dateobjectname = new date("month day, year hours:minutes:seconds")
3. dateobjectname = new date(year, month, day)
4. dateobjectname = new date(year, month, day, hours, minutes, seconds)
to use a date object:

1. dateobjectname.propertyname
2. dateobjectname.methodname(parameters)
exceptions: the date object's parse and utc methods are static methods that you use as follows:

date.utc(parameters)
date.parse(parameters)

parameters

dateobjectname is either the name of a new object or a property of an existing object. when using date properties and methods, dateobjectname is either the name of an existing date object or a property of an existing object.

month, day, year, hours, minutes, and seconds are string values for form 2 of the syntax. for forms 3 and 4, they are integer values.

propertyname is one of the properties listed below.

methodname is one of the methods listed below.

property of

none

implemented in

description

the date object is a built-in javascript object.

form 1 of the syntax creates today's date and time. if you omit hours, minutes, or seconds from form 2 or 4 of the syntax, the value will be set to zero.

the way javascript handles dates is very similar to the way java handles dates: both languages have many of the same date methods, and both store dates internally as the number of milliseconds since january 1, 1970 00:00:00. dates prior to 1970 are not allowed.

properties

the date object has the following properties:

property description
prototype lets you add a properties to a date object.

methods

the date object has the following methods:

  • eval
  • getdate
  • getday
  • gethours
  • getminutes
  • getmonth
  • getseconds
  • gettime
  • gettimezoneoffset
  • getyear
  • parse
  • setdate
  • sethours
  • setminutes
  • setmonth
  • setseconds
  • settime
  • setyear
  • togmtstring
  • tolocalestring
  • tostring
  • utc
  • valueof
  • event handlers

    none.

    examples

    the following examples show several ways to assign dates:

    today = new date()
    birthday = new date("december 17, 1995 03:24:00")
    birthday = new date(95,12,17)
    birthday = new date(95,12,17,3,24,0)

    defaultchecked

    property. a boolean value indicating the default selection state of a checkbox or radio button.

    syntax

    1. checkboxname.defaultchecked
    2. radioname[index].defaultchecked

    parameters

    checkboxname is either the value of the name attribute of a checkbox object or an element in the elements array.

    radioname is the value of the name attribute of a radio object.

    index is an integer representing a radio button in a radio object.

    property of

    checkbox, radio

    implemented in

    navigator 2.0

    tainted?

    yes

    description

    if a checkbox or radio button is selected by default, the value of the defaultchecked property is true; otherwise, it is false. defaultchecked initially reflects whether the checked attribute is used within an <input> tag; however, setting defaultchecked overrides the checked attribute.

    you can set the defaultchecked property at any time. the display of the checkbox or radio button does not update when you set the defaultchecked property, only when you set the checked property.

    examples

    the following example resets an array of radio buttons called musictype on the musicform form to the default selection state:

    function radioresetter() {
       var i=""
       for (i in document.musicform.musictype) {
          if (document.musicform.musictype[i].defaultchecked==true) {
             document.musicform.musictype[i].checked=true
          }
       }
    }

    see also

    checked property


    defaultselected

    property. a boolean value indicating the default selection state of an option in a select object.

    syntax

    selectname.options[index].defaultselected
    optionname.defaultselected

    parameters

    selectname is either the value of the name attribute of a select object or an element in the elements array.

    index is an integer representing an option in a select object.

    optionname is the name of a select object option created using the option() constructor.

    property of

    option object (see select object), options array (see select object)

    implemented in

    tainted?

    yes

    description

    if an option in a select object is selected by default, the value of the defaultselected property is true; otherwise, it is false. defaultselected initially reflects whether the selected attribute is used within an <option> tag; however, setting defaultselected overrides the selected attribute.

    you can set the defaultselected property at any time. the display of the select object does not update when you set the defaultselected property, only when you set the selected or selectedindex properties.

    a select object created without the multiple attribute can have only one option selected by default. when you set defaultselected in such an object, any previous default selections, including defaults set with the selected attribute, are cleared. if you set defaultselected in a select object created with the multiple attribute, previous default selections are not affected.

    examples

    in the following example, the restoredefault function returns the musictype select object to its default state. the for loop uses the options array to evaluate every option in the select object. the if statement sets the selected property if defaultselected is true.

    function restoredefault() {
       for (var i = 0; i < document.musicform.musictype.length; i++) {
          if (document.musicform.musictype.options[i].defaultselected == true) {
             document.musicform.musictype.options[i].selected=true
          }
       }
    }
    the previous example assumes that the select object is similar to the following:

    <select name="musictype"> 
       <option selected> r&b
       <option> jazz
       <option> blues
       <option> new age
    </select>

    see also

    index, selected, selectedindex properties


    defaultstatus

    property. the default message displayed in the status bar at the bottom of the window.

    syntax

    windowreference.defaultstatus

    parameters

    windowreference is a valid way of referring to a window, as described in the window object.

    property of

    window object

    implemented in

    navigator 2.0

    tainted?

    yes

    description

    the defaultstatus message appears when nothing else is in the status bar. do not confuse the defaultstatus property with the status property. the status property reflects a priority or transient message in the status bar, such as the message that appears when a mouseover event occurs over an anchor.

    you can set the defaultstatus property at any time. you must return true if you want to set the defaultstatus property in the onmouseout or onmouseover event handlers.

    examples

    in the following example, the statussetter function sets both the status and defaultstatus properties in an onmouseover event handler:

    function statussetter() {
       window.defaultstatus = "click the link for the netscape home page"
       window.status = "netscape home page"
    }

    <a href="http://home.netscape.com"
       onmouseover = "statussetter(); return true">netscape</a>
    in the previous example, notice that the onmouseover event handler returns a value of true. you must return true to set status or defaultstatus in an event handler.

    see also

    status property


    defaultvalue

    property. a string indicating the default value of a password, text, or textarea object.

    syntax

    1. passwordname.defaultvalue
    2. textname.defaultvalue
    3. textareaname.defaultvalue

    parameters

    passwordname is either the value of the name attribute of a password object or an element in the elements array.

    textname is either the value of the name attribute of a text object or an element in the elements array.

    textareaname is either the value of the name attribute of a textarea object or an element in the elements array.

    property of

    password object, text object, textarea object

    implemented in

    navigator 2.0

    tainted?

    yes

    description

    the initial value of defaultvalue differs for each object:

    setting defaultvalue programmatically overrides the initial setting. if you programmatically set defaultvalue for the password object and then evaluate it, javascript returns the current value.

    you can set the defaultvalue property at any time. the display of the related object does not update when you set the defaultvalue property, only when you set the value property.

    examples

    the following function evaluates the defaultvalue property of objects on the surfcity form and displays the values in the msgwindow window:

    function defaultgetter() {
       msgwindow=window.open("")
       msgwindow.document.write("hidden.defaultvalue is " +
          document.surfcity.hiddenobj.defaultvalue + "<br>")
       msgwindow.document.write("password.defaultvalue is " +
          document.surfcity.passwordobj.defaultvalue + "<br>")
       msgwindow.document.write("text.defaultvalue is " +
          document.surfcity.textobj.defaultvalue + "<br>")
       msgwindow.document.write("textarea.defaultvalue is " +
          document.surfcity.textareaobj.defaultvalue + "<br>")
       msgwindow.document.close()
    }

    see also

    value property


    description

    property. a description of a mime type or plug-in.

    syntax

    1. navigator.mimetypes[index1].description
    2. navigator.plugins[index2].description

    parameters

    index1 is either an integer representing a mime type supported by the client or a string containing the type of a mimetype object (from the type property).

    index2 is either an integer representing a plug-in installed on the client or a string containing the name of a plugin object (from the name property).

    property of

    implemented in

    navigator 3.0

    tainted?

    no

    description

    for mimetype objects, the description property is a description of the content and encoding for the mime data type.

    for plugin objects, the description property is a description of the plug-in. the description is supplied by the plug-in itself.

    description is a read-only property.

    examples

    see the examples for the mimetype and plugin objects.

    see also

    for mimetype objects: enabledplugin, type, suffixes properties

    for plugin objects: filename, length, name properties


    document

    object. contains information on the current document, and provides methods for displaying html output to the user.

    html syntax

    to define a document object, use standard html syntax with the addition of javascript event handlers:

    <body
       background="backgroundimage"
       bgcolor="backgroundcolor"
       text="foregroundcolor"
       link="unfollowedlinkcolor"
       alink="activatedlinkcolor"
       vlink="followedlinkcolor"
       [onblur="handlertext"]
       [onfocus="handlertext"]
       [onload="handlertext"]
       [onunload="handlertext"]>
    </body>

    html attributes

    background specifies an image that fills the background of the document.

    bgcolor, text, link, alink, and vlink are color specifications expressed as a hexadecimal rgb triplet (in the format "rrggbb" or "#rrggbb") or as one of the string literals listed in "color values".

    syntax

    to use a document object's properties and methods:

    1. document.propertyname
    2. document.methodname(parameters)

    parameters

    propertyname is one of the properties listed below.

    methodname is one of the methods listed below.

    property of

    window object

    implemented in

    description

    an html document consists of <head> and <body> tags. the <head> tag includes information on the document's title and base (the absolute url base to be used for relative url links in the document). the <body> tag encloses the body of a document, which is defined by the current url. the entire body of the document (all other html elements for the document) goes within the <body> tag.

    you can load a new document by using the window.location object.

    you can clear the document pane (and remove the text, form elements, and so on so they do not redisplay) by using document.close(); document.open(); document.write(). you can omit the document.open() call if you are writing text or html, since write does an implicit open of that mime type if the document stream is closed.

    you can reference the anchors, forms, and links of a document by using the anchors, forms, and links arrays. these arrays contain an entry for each anchor, form, or link in a document.

    do not use location as a property of the document object; use the document.url property instead. the document.location property, which is a synonym for document.url, will be removed in a future release.

    properties

    the document object has the following properties:

    property description
    alinkcolor reflects the alink attribute
    anchors an array reflecting all the anchors in a document
    applets an array reflecting all the applets in a document
    bgcolor reflects the bgcolor attribute
    cookie specifies a cookie
    domain specifies the domain name of the server that served a document
    embeds array an array reflecting all the plugins in a document
    fgcolor reflects the text attribute
    forms an array reflecting all the forms in a document
    images an array reflecting all the images in a document
    lastmodified reflects the date a document was last modified
    linkcolor reflects the link attribute
    links an array reflecting all the links in a document
    referrer reflects the url of the calling document
    title reflects the contents of the <title> tag
    url reflects the complete url of a document
    vlinkcolor reflects the vlink attribute

    the following objects are also properties of the document object:

  • anchor object
  • applet
  • area (see link object)
  • form object
  • image
  • link object
  • methods

    the document object has the following methods:

  • close (document object)
  • eval
  • open (document object)
  • tostring
  • valueof
  • write
  • writeln
  • event handlers

    none. the onblur, onfocus, onload, and onunload event handlers are specified in the <body> tag but are actually event handlers for the window object.

    examples

    the following example creates two frames, each with one document. the document in the first frame contains links to anchors in the document of the second frame. each document defines its colors.

    doc0.html, which defines the frames, contains the following code:

    <html>
    <head>
    <title>document object example</title>
    </head>
    <frameset cols="30%,70%">
    <frame src="doc1.html" name="frame1">
    <frame src="doc2.html" name="frame2">
    </frameset>
    </html>
    doc1.html, which defines the content for the first frame, contains the following code:

    <html>
    <script>
    </script>
    <body
       bgcolor="antiquewhite"
       text="darkviolet"
       link="fuchsia"
       alink="forestgreen"
       vlink="navy">
    <p><b>some links</b>
    <li><a href="doc2.html#numbers" target="frame2">numbers</a>
    <li><a href="doc2.html#colors" target="frame2">colors</a>
    <li><a href="doc2.html#musictypes" target="frame2">music types</a>
    <li><a href="doc2.html#countries" target="frame2">countries</a>
    </body>
    </html>
    doc2.html, which defines the content for the second frame, contains the following code:

    <html>
    <script>
    </script>
    <body
       bgcolor="oldlace" onload="alert('hello, world.')"
       text="navy">
    <p><a name="numbers"><b>some numbers</b></a>
    <ul><li>one
    <li>two
    <li>three
    <li>four</ul>
    <p><a name="colors"><b>some colors</b></a>
    <ul><li>red
    <li>orange
    <li>yellow
    <li>green</ul>
    <p><a name="musictypes"><b>some music types</b></a>
    <ul><li>r&b
    <li>jazz
    <li>soul
    <li>reggae</ul>
    <p><a name="countries"><b>some countries</b></a>
    <ul><li>afghanistan
    <li>brazil
    <li>canada
    <li>finland</ul>
    </body>
    </html>

    see also

    frame object, window object


    domain

    property. specifies the domain name of the server that served a document.

    syntax

    document.domain

    property of

    document

    tainted?

    yes

    implemented in

    navigator 3.0

    description

    the domain property lets scripts on multiple servers share properties when data tainting is not enabled. with tainting disabled, a script running in one window can read properties of another window only if both windows come from the same web server. but large web sites with multiple servers might need to share properties among servers. for example, a script on the host www.yahoo.com might need to share properties with a script on the host search.yahoo.com.

    if scripts on two different servers change their domain property so that both scripts have the same domain name, both scripts can share properties. for example, a script loaded from search.yahoo.com could set its domain property to "yahoo.com". a script from www.yahoo.com running in another window could also set its domain property to "yahoo.com". then, since both scripts have the domain "yahoo.com", these two scripts can share properties, even though they did not originate from the same server.

    you can change domain only in a restricted way. initially, domain contains the hostname of the web server from which the document was loaded. you can set domain only to a domain suffix of itself. for example, a script from search.yahoo.com can't set its domain property to "search.yahoo". and a script from iwantyourmoney.com cannot set its domain to "yahoo.com".

    once you change the domain property, you cannot change it back to its original value. for example, if you change domain from "search.yahoo.com" to "yahoo.com", you cannot reset it to "search.yahoo.com".

    you can change domain at any time.

    examples

    the following statement changes the domain property to "bravenewworld.com". this statement is valid only if "bravenewworld.com" is a suffix of the current domain, such as "www.bravenewworld.com".

    document.domain="bravenewworld.com"

    see also

    taint, untaint functions; "using data tainting for security"


    e

    property. euler's constant and the base of natural logarithms, approximately 2.718.

    syntax

    math.e

    property of

    math

    implemented in

    navigator 2.0

    tainted?

    no

    description

    because e is a constant, it is a read-only property of math.

    examples

    the following function returns euler's constant:

    function geteuler() {
       return math.e
    }

    see also

    exp, ln2, ln10, log2e, log10e, pi, sqrt1_2, sqrt2 properties


    elements array

    property. an array of objects corresponding to form elements (such as checkbox, radio, and text objects) in source order.

    syntax

    1. formname.elements[index]
    2. formname.elements.length

    parameters

    formname is either the name of a form or an element in the forms array.

    index is an integer representing an object on a form or the name of an object as specified by the name attribute.

    property of

    form object

    implemented in

    navigator 2.0

    tainted?

    no

    description

    you can reference a form's elements in your code by using the elements array. this array contains an entry for each object (button, checkbox, fileupload, hidden, password, radio, reset, select, submit, text, or textarea object) in a form in source order. for example, if a form has a text field and two checkboxes, these elements are reflected as formname.elements[0], formname.elements[1], and formname.elements[2].

    although you can also reference a form's elements by using the element's name (from the name attribute), the elements array provides a way to reference form objects programmatically without using their names. for example, if the first object on the userinfo form is the username text object, you can evaluate it in either of the following ways:

    userinfo.username.value
    userinfo.elements[0].value
    to obtain the number of elements on a form, use the length property: formname.elements.length. each radio button in a radio object appears as a separate element in the elements array.

    elements in the elements array are read-only. for example, the statement formname.elements[0]="music" has no effect.

    the value of each element in the elements array is the full html statement for the object.

    properties

    the elements array has the following properties:

    property description
    length reflects the number of elements in the form

    examples

    see the examples for the frame property.

    see also

    form object


    elements property

    property. an array of objects corresponding to form elements (such as checkbox, radio, and text objects) in source order. see the elements array for information.


    embeds array

    property. an array reflecting all the <embed> tags in a document in source order.

    html syntax

    to generate output from a plug-in application, use standard html syntax:

    <embed
       src=source
       name=embedname
       height=height
       width=width>
       
    [parametername=parametervalue]
       [ ... parametername=parametervalue]
    </embed>
    for the complete syntax of the <embed> tag, see http://home.netscape.com/eng/mozilla/3.0/handbook/plugins/index.html.

    html attributes

    src=source</i> specifies the url containing the source content.

    name=embedname specifies the name of the embedded object in the document. you can use this name when indexing the embeds array.

    height=height specifies the height of the applet in pixels within the browser window.

    width=width specifies the width of the applet in pixels within the browser window.

    parametername=parametervalue specifies the name and value of a parameter to pass to the embedded object's plug-in.

    property of

    document

    implemented in

    navigator 3.0

    tainted?

    no

    description

    you can reference embedded objects (created with the <embed> tag) in your code by using the embeds array. this array contains an entry for each <embed> tag in a document in source order. for example, if a document contains three <embed> tags, these <embed> tags are reflected as document.embeds[0], document.embeds[1], and document.embeds[2].

    elements in the embeds array may have public callable functions, if they reference a "liveconnected" plug-in. see chapter 4, "liveconnect."

    to use the embeds array:

    1. document.embeds[index]
    2. document.embeds.length
    index is an integer representing an <embed> tag or the name of an embedded object as specified by the name attribute.

    to obtain the number of <embed> tags in a document, use the length property: document.embeds.length.

    use the elements in the embeds array to interact with the plug-in that is displaying the embedded object. if a plug-in is not java-enabled, you cannot do anything with its element in the embeds array. the fields and methods of the elements in the embeds array vary from plug-in to plug-in; see the documentation supplied by the plug-in manufacturer.

    when you use the <embed> tag to generate output from a plug-in application, you are not creating a plugin object. see the plugin object.

    elements in the embeds array are read-only. for example, the statement document.embeds[0]="myavi.avi" has no effect.

    properties

    the embeds array has the following properties:

    property description
    length reflects the number of elements in the array

    methods

    event handlers

  • none.

    examples

    the following code includes an audio plug-in in a document.

    <embed src="train.au" height=50 width=250>

    see also

    plugin object


    enabledplugin

    property. the plugin object for the plug-in that is configured for the specified mime type.

    syntax

    navigator.mimetypes[index].enabledplugin

    parameters

    index is either an integer representing a mime type supported by the client or a string containing the type of a mimetype object (from the type property).

    property of

    mimetype

    implemented in

    navigator 3.0

    tainted?

    no

    description

    use the enabledplugin property to determine which plug-in is configured for a specific mime type. each plug-in may support multiple mime types, and each mime type could potentially be supported by multiple plug-ins. however, only one plug-in can be configured for a mime type. (on macintosh and unix, the user can configure the handler for each mime type; on windows, the handler is determined at navigator start-up time.)

    the enabledplugin property is a reference to a plugin object that represents the plug-in that is configured for the specified mime type. if the mime type does not have a plug-in configured, enabledplugin is null.

    without the enabledplugin property, you could determine if the user has a particular plug-in installed, if their navigator can handle a particular mime type, and if the mime type is supported by any plug-ins. but you could not determine whether a plug-in is configured for the mime type. you might need to know this information, for example, so you could dynamically emit an <embed> tag on the page if the user has a plug-in configured for the mime type.

    enabledplugin is a read-only property.

    examples

    the following example determines whether the shockwave plug-in is installed. if it is, a movie is displayed.

    // can we display shockwave movies?
    mimetype = navigator.mimetypes["application/x-director"]
    if (mimetype) {
       // yes, so can we display with a plug-in?
       plugin = mimetype.enabledplugin
       if (plugin)
          // yes, so show the data in-line
          document.writeln("here\'s a movie: <embed src=mymovie.dir height=100 width=100>")
          else
          // no, so provide a link to the data
          document.writeln("<a href='mymovie.dir>click here</a> to see a movie.")
       } else {
       // no, so tell them so
       document.writeln("sorry, can't show you this cool movie.")
    }
    see also the examples for the mimetype object.

    see also

    description, type, suffixes properties


    encoding

    property. a string specifying the mime encoding of the form.

    syntax

    formname.encoding

    parameters

    formname is either the name of a form or an element in the forms array.

    property of

    form object

    implemented in

    navigator 2.0

    tainted?

    no

    description

    the encoding property initially reflects the enctype attribute of the <form> tag; however, setting encoding overrides the enctype attribute.

    you can set the encoding property at any time.

    examples

    the following function returns the value of the musicform encoding property:

    function getencoding() {
       return document.musicform.encoding
    }

    see also

    action, method, target properties; form object


    escape

    function. returns the ascii encoding of an argument in the iso latin-1 character set.

    syntax

    escape("string")

    parameters

    string is a nonalphanumeric string in the iso latin-1 character set, or a property of an existing object.

    implemented in

    navigator 2.0

    description

    the value returned by the escape function is a string of the form "%xx," where xx is the ascii encoding of a character in the argument. if you pass the escape function an alphanumeric character, the escape function returns the same character. escape is a top-level function not associated with any object.

    examples

    the following example returns "hello%2c%20world":

    escape("hello, world")
    the following example returns "%26":

    escape("&")
    the following example returns "%21%23":

    escape("!#")

    see also

    unescape function


    eval

    method. the eval method evaluates a string of javascript code in the context of the specified object.

    syntax

    [objectname.]eval(string)

    parameters

    objectname is the object for which a string is to be evaluated. if omitted, the string is evaluated without regard to any object.

    string is any string representing a javascript expression, statement, or sequence of statements. the expression can include variables and properties of existing objects.

    method of

    eval is a method of all objects.

    implemented in

    navigator 2.0: a built-in javascript function, not associated with any object, but part of the language itself

    navigator 3.0: a method of every object

    description

    the argument of the eval method is a string. if the string represents an expression, eval evaluates the expression. if the argument represents one or more javascript statements, eval performs the statements. do not call eval to evaluate an arithmetic expression; javascript evaluates arithmetic expressions automatically.

    if you construct an arithmetic expression as a string, you can use eval to evaluate it at a later time. for example, suppose you have a variable x. you can postpone evaluation of an expression involving x by assigning the string value of the expression, say "3 * x + 2", to a variable, and then calling eval at a later point in your script.

    examples

    example 1. both of the write statements below display 42. the first evaluates the string "x + y + 1," and the second evaluates the string "42."

    var x = 2
    var y = 39
    var z = "42"
    document.write(eval("x + y + 1"), "<br>")
    document.write(eval(z), "<br>")
    example 2. in the following example, the getfieldname(n) function returns the name of the nth form element as a string. the first statement assigns the string value of the third form element to the variable field. the second statement uses eval to display the value of the form element.

    var field = getfieldname(3) 
    document.write("the field named ", field, " has value of ", eval(field + ".value"))
    example 3. the following example uses eval to evaluate the string str. this string consists of javascript statements that open an alert dialog box and assigns z a value of 42 if x is five, and assigns zero to z otherwise. when the second statement is executed, eval will cause these statements to be performed, and it will also evaluate the set of statements and return the value that is assigned to z.

    var str = "if (x == 5) {alert('z is 42'); z = 42;} else z = 0; "
    document.write("<p>z is ", eval(str))
    example 4. in the following example, the setvalue function uses eval to assign the value of the variable newvalue to the text field textobject:

    function setvalue (textobject, newvalue) {
       eval ("document.forms[0]." + textobject + ".value") = newvalue
    }
    example 5. the following example creates breed as a property of the object mydog, and also as a variable. the first write statement uses eval('breed') without specifying an object; the string "breed" is evaluated without regard to any object, and the write method displays "shepherd", which is the value of the breed variable. the second write statement uses mydog.eval('breed') which specifies the object mydog; the string "breed" is evaluated with regard to the mydog object, and the write method displays "lab", which is the value of the breed property of the mydog object.

    function dog(name,breed,color) {
       this.name=name
       this.breed=breed
       this.color=color
    }
    mydog = new dog("gabby")
    mydog.breed="lab"
    var breed='shepherd'
    document.write("<p>" + eval('breed'))
    document.write("<br>" + mydog.eval('breed'))
    example 6. the following example uses eval within a function that defines an object type, flintstone. the statement fred = new flintstone("x=42") creates the object fred with the properties x, y, z, and z2. the write statements display the values of these properties as 42, 43, 44, and 45, respectively.

    function flintstone(str) {
       this.eval("this."+str)
       this.eval("this.y=43")
       this.z=44
       this["z2"] = 45
    }
    fred = new flintstone("x=42")
    document.write("<br>fred.x is " + fred.x)
    document.write("<br>fred.y is " + fred.y)
    document.write("<br>fred.z is " + fred.z)
    document.write("<br>fred.z2 is " + fred.z2)

    exp

    method. returns enumber, where number is the argument, and e is euler's constant, the base of the natural logarithms.

    syntax

    math.exp(number)

    parameters

    number is any numeric expression or a property of an existing object.

    method of

    math

    implemented in

    navigator 2.0

    examples

    the following function returns the exp value of the variable x:

    function getexp(x) {
       return math.exp(x)
    }
    if you pass getexp the value 1, it returns 2.718281828459045.

    see also

    e, log, pow methods


    [next reference file]