Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Class inheritance#274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vplentinax merged 6 commits intojavascript-tutorial:masterfromcortizg:es.javascript.info.1-09-02-ci
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
That's because the child constructormust call `super()`.
Eso es porque el constructorhijo debe llamar a `super()`.

Here's the corrected code:
Aqui el código corregido:

```js run
class Animal {
Expand All@@ -21,7 +21,7 @@ class Rabbit extends Animal {
}

*!*
let rabbit = new Rabbit("White Rabbit"); //ok now
let rabbit = new Rabbit("Conejo Blanco"); //ahora funciona
*/!*
alert(rabbit.name); //White Rabbit
alert(rabbit.name); //Conejo Blanco
```
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,11 @@ importance: 5

---

# Errorcreating an instance
# Erroral crear una instancia

Here's the code with`Rabbit`extending `Animal`.
Aquí está el código de la clase`Rabbit`que extiende a `Animal`.

Unfortunately,`Rabbit`objects can't be created. What's wrong? Fix it.
Desafortunadamente, los objetos`Rabbit`no se pueden crear. ¿Que pasa? Arréglalo.
```js run
class Animal {

Expand All@@ -24,7 +24,7 @@ class Rabbit extends Animal {
}

*!*
let rabbit = new Rabbit("White Rabbit"); // Error:this is not defined
let rabbit = new Rabbit("Conejo Blanco"); // Error:esto no está definido
*/!*
alert(rabbit.name);
```
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@
clock.start();


/*Your class should work like this: */
/*Tu clase debería funcionar así: */

/*

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,14 +2,14 @@ importance: 5

---

#Extended clock
#Reloj extendido

We've got a `Clock` class. As of now, it prints the time every second.
Tenemos una clase de 'Clock'. A partir de ahora, imprime la hora cada segundo.


[js src="source.view/clock.js"]

Create a new class `ExtendedClock`that inherits from `Clock`and adds the parameter `precision` -- the number of `ms` between "ticks".Should be `1000` (1second) by default.
Crea una nueva clase `ExtendedClock`que herede de `Clock`y agrega el parámetro `precision`: este es el número de `milisegundos` entre "tics".Debe ser `1000` (1segundo) por defecto.

-Your code should be in the file `extended-clock.js`
-Don't modify the original`clock.js`. Extend it.
-Tu código debe estar en el archivo `extended-clock.js`
-No modifiques el`clock.js` original. Extiéndelo.
View file
Open in desktop

This file was deleted.

View file
Open in desktop

This file was deleted.

View file
Open in desktop

This file was deleted.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp