JavaScript Handbook-E

zhaozj2021-02-17  53

E Property

Euler's constant and the base of natural logarithms, ApproxImately 2.718.

grammar

Math.e

Property of

Math

description

Because e is a constant, IT is a read-only Property of Math.

example

The Following Example Displays Euler's Constant:

Document.write ("Euler's constant is" math.e)

See Also

LN2, LN10, LOG2E, LOG10E, PI, SQRT1_2, SQRT2 Properties

Elements Array An Array Objects Corresponding To Form Elements (Such as Checkbox, Radio, and Text Objects) in Source Order. Syntax 1. FormName.ersion [Index]

2. Formname.ements.Length

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. Property of description form 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, 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 programatically 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 htm statement for the object. Properties length reflects the number of elements on a form See the examples for example The name Property. See Also form ObjectElements Property An Array Objects Corresponding To Form Elements in Source Order. See elements array.

encoding property A string specifying the MIME encoding of the form. Syntax formName.encoding formName is either the name of a form or an element in the forms array. Property of form Description The encoding property initially reflects the ENCTYPE attribute of the

tag ;.... however, setting encoding overrides the ENCTYPE attribute You can set the encoding property at any time Certain values ​​of the encoding property may require specific values ​​for other form properties See RFC 1867 for more information examples The following function returns the value of The Musicform Encoding Property: Function GetENCODING () {

Return Document.musicForm.Encoding

}

See Also Action, Method, Target Properties

escape function Returns the ASCII encoding of an argument in the ISO Latin-1 character set. Syntax escape ( "string") string is a non-alphanumeric string in the ISO Latin-1 character set, or a property of an existing object. Description The escape function is not a method associated with any object, but is part of the language itself. 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. examples The following example returns "% 26" escape ( "&") The following example returns "% 21% 23" escape ( "! #" )

See Also Unescape Function

eval function The eval function evaluates a string and returns a value. Syntax eval (string) string is any string representing a JavaScript expression, statement, or sequence of statements. The expression can include variables and properties of existing objects. Description The eval function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself. The argument of the eval function is a string. Do not call eval to evaluate an arithmetic expression. JavaScript evaluates arithmetic expressions automatically . If the argument represents an expression, eval evaluates the expression. If the argument represents one or more JavaScript statements, eval performs the statements. 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 evolving x by assigning the string value of the expression, Say "3 * x 2" to a var Iable, And The Calling Eval At A Later Point In Your Script. Example Example 1. Both of the Write Statements Below Display 42. The first evatates the string "x y 1", and the second evanuates the string "42". Var x = 2VAR Y = 39

Var z = "42"

Document.write (EVAL ("x y 1"), "
")

Document.write (Eval (z), "
")

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 opens an alert dialog box and assigns za 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 ("

z IS", EVAL (STR))

Example 4. In The Following Example, The SetValue () Function Uses Eval To Assign To The text Field TextObject. Function SetValue (TextObject, NewValue) {

Eval ("Document.Forms [0]." TextObject ".value" = newValue

}

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) number is any numeric expression or a property of an existing object. Method of Math Examples // Displays the value 2.718281828459045

Document.write ("THE VALUE OF E 1 is" Math.exp (1))

See Also Log, Pow Methods

转载请注明原文地址:https://www.9cbs.com/read-30718.html

New Post(0)