You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Defines shared properties for all [Creations](#class-creation) created by *this*[Generation](#class-generation).
@@ -171,31 +184,11 @@ Person.definePrototype(
171
184
172
185
```
173
186
174
-
<aname="generation-create"></a>
175
-
## Generation.create()
176
-
177
-
**return*: `Creation` A new [Creation](#class-creation) that inherits from *this*[Generation.proto](#generation-proto).
178
-
179
-
Creates a new [Creation](#class-creation) that inherits from *this*[Generation.proto](#generation-proto).
180
-
181
-
Example:
182
-
```javascript
183
-
var jim =Person.create('Jim', 10, 'male');
184
-
185
-
jim.name// 'Jim'
186
-
jim.age// 10
187
-
jim.sex// 'male'
188
-
189
-
jim.sayHello(); // prints out: 'Hello, my name is Jim. What is yours?'
190
-
jim.sayBye(); // prints out: 'Goodbye.'
191
-
192
-
```
193
-
194
187
<aname="generation-generate"></a>
195
188
## Generation.generate(create)
196
189
197
-
**create*`Function`Create method that gets called when creating a new object that inherits from *this*[Generation.proto](#generation-proto).
198
-
**return*: `Generation` A new [Generation](#class-generation) that inherits from *this*[Generation](#class-generation).
190
+
**create*`Function`Constructor that with inherit form [Generation](#class-generation).
191
+
**return*: `Constructor` The inputed `create` function.
199
192
200
193
Returns a new [Generation](#class-generation) that inherits from *this*[Generation](#class-generation).
201
194
@@ -204,9 +197,7 @@ Example:
204
197
var Student =Person.generate(
205
198
/* create method */
206
199
functionStudent(name, age, sex, studentId) {
207
-
// 'supercreate' method is only available in this create method scope.
208
-
// NOTE: if the 'supercreate' method is not called implicitly it will be called with no arguments.
209
-
this.supercreate(name, age, sex);
200
+
Person.call(this, name, age, sex);
210
201
this.studentId= studentId ||'A0000000000';
211
202
}
212
203
);
@@ -222,7 +213,7 @@ Student.definePrototype(
222
213
}
223
214
);
224
215
225
-
var sarah =Student.create('Sarah', 17, 'female', 'A0123456789');
216
+
var sarah =newStudent('Sarah', 17, 'female', 'A0123456789');
226
217
227
218
sarah.name// 'Sarah'
228
219
sarah.age// 17
@@ -248,12 +239,12 @@ Returns `true` if *test* inherits from *this* [Generation](#class-generation), `
248
239
**test*`Object` An Object to be tested.
249
240
**return*: `Boolean``true` or `false`.
250
241
251
-
Returns `true` if *test*inherits from *this*[Generation.proto](#generation-proto), `false` otherwise.
242
+
Returns `true` if *test*is an instance of *this*[Generation](#generation), `false` otherwise.
252
243
253
244
<aname="class-creation"></a>
254
245
## Class: Creation
255
246
256
-
A new Creation that inherits from a [Generation's proto](#generation-proto) that created it using the [Generation.create()](#generation-create) method.
247
+
A instance [Generation](#generation) that created it using the [new Generation()](#generation-create).
0 commit comments