Class Complex
Defined in: complex2.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Complex(real, imaginary)
The first step in defining a class is defining the constructor
function of the class.
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
Complex.add(a, b)
Add two complex numbers and return the result.
|
| <static> |
Complex.multiply(a, b)
|
|
negative()
|
|
| <static> |
Complex.subtract(a, b)
|
|
toString()
|
|
|
valueOf()
|
Class Detail
Complex(real, imaginary)
The first step in defining a class is defining the constructor
function of the class. This constructor should initialize any
instance properties of the object. These are the essential
"state variables" that make each instance of the class different.
- Parameters:
- real
- {Number} The real part
- imaginary
- {Number} The complex part
Method Detail
<static>
{Complex}
Complex.add(a, b)
Add two complex numbers and return the result.
- Parameters:
- a
- {Complex} A complex number
- b
- {Complex} A second complex number
- Returns:
- {Complex} The sum of a and b
magnitude()
<static>
Complex.multiply(a, b)
- Parameters:
- a
- b
negative()
<static>
Complex.subtract(a, b)
- Parameters:
- a
- b
toString()
valueOf()