Skip to content

Commit 3fcb463

Browse files
committed
Document methods and properties
1 parent 78d81a3 commit 3fcb463

File tree

1 file changed

+112
-0
lines changed
  • lib/node_modules/@stdlib/function/ctor

1 file changed

+112
-0
lines changed

lib/node_modules/@stdlib/function/ctor/README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,118 @@ var v = greet( 'Jane' );
5353

5454
Argument names must be strings corresponding to valid JavaScript parameters (i.e., a plain identifier, or, in environments supporting such parameters, a rest parameter or destructured parameter, optionally with a default).
5555

56+
* * *
57+
58+
### Properties
59+
60+
<a name="prop-length"></a>
61+
62+
#### Function.prototype.length
63+
64+
A number representing the number of arguments expected by the function.
65+
66+
```javascript
67+
var greet = new Function( 'name', 'return "Hello, "+name+"!"' );
68+
var v = greet.length;
69+
// returns 1
70+
```
71+
72+
<a name="prop-name"></a>
73+
74+
#### Function.prototype.name
75+
76+
**Read-only** property representing the name of the function.
77+
78+
```javascript
79+
function greet( name ) {
80+
return 'Hello, '+name+'!';
81+
}
82+
v = greet.name;
83+
// returns 'greet'
84+
85+
// Functions created with the Function constructor are anonymous:
86+
var fcn = new Function( 'name', 'return "Hello, "+name+"!"' );
87+
var v = fcn.name;
88+
// returns 'anonymous'
89+
```
90+
91+
<a name="prop-prototype"></a>
92+
93+
#### Function.prototype.prototype
94+
95+
**Read-only** property representing the prototype of the function.
96+
97+
```javascript
98+
function greet( name ) {
99+
return 'Hello, '+name+'!';
100+
}
101+
var proto = greet.prototype;
102+
// returns {}
103+
```
104+
105+
* * *
106+
107+
### Methods
108+
109+
<a name="method-apply"></a>
110+
111+
#### Function.prototype.apply( thisArg, args )
112+
113+
Calls the specified function witht he given `this` argument and arguments provided as an array-like object.
114+
115+
```javascript
116+
function add( x, y ) {
117+
return x + y;
118+
}
119+
var v = add.apply( null, [ 1, 2 ] );
120+
// returns 3
121+
```
122+
123+
<a name="method-bind"></a>
124+
125+
#### Function.prototype.bind( thisArg\[, arg1\[, arg2\[, ...]]] )
126+
127+
Returns a new function which invokes the original function with the given `this` value and arguments.
128+
129+
```javascript
130+
functiona add( x, y ) {
131+
return x + y;
132+
}
133+
var add1 = add.bind( null, 1 );
134+
135+
var v = add1( 2 );
136+
// returns 3
137+
```
138+
139+
<a name="method-call"></a>
140+
141+
#### Function.prototype.call( thisArg\[, arg1\[, arg2\[, ...]]] )
142+
143+
Calls the specified function with the given `this` value and arguments.
144+
145+
```javascript
146+
function add( x, y ) {
147+
return x + y;
148+
}
149+
150+
var v = add.call( null, 1, 2 );
151+
// returns 3
152+
```
153+
154+
<a name="method-to-string"></a>
155+
156+
#### Function.prototype.toString()
157+
158+
Returns a string representing the function.
159+
160+
```javascript
161+
function add( x, y ) {
162+
return x + y;
163+
}
164+
var v = add.toString();
165+
// returns 'function add( x, y ) {\n return x + y;\n}'
166+
```
167+
56168
</section>
57169

58170
<!-- /.usage -->

0 commit comments

Comments
 (0)