GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Constructor, operator "new" by PedroDousseau · Pull Request #88 · javascript-tutorial/pt.javascript.info ConversationArticle translated
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
| --- | ||
|
|
||
| # Create new Calculator | ||
| # Crie uma calculadora new |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| --- | ||
|
|
||
| # Create new Accumulator | ||
| # Crie um acumulador new |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| let accumulator = new Accumulator(1); // valor inicial 1 | ||
| accumulator.read(); // adiciona o valor digitado pelo usuário | ||
| accumulator.read(); // adiciona o valor digitado pelo usuário | ||
| alert(accumulator.value); // apresenta a soma destses valores |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # Construtor, operador "new" | ||
|
|
||
| The regular `{...}` syntax allows to create one object. But often we need to create many similar objects, like multiple users or menu items and so on. | ||
| A sintaxe regular `{...}` permite criar um objeto. Mas frequentemente precisamos criar vários objetos iguais, como diversos usuários, itens de um menu, etc. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| 1. They are named with capital letter first. | ||
| 2. They should be executed only with `"new"` operator. | ||
| 1. Elas são nomeadas com a primeira letra em maiúsculo. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| john.sayHi(); // Meu nome é: John | ||
| */!* | ||
|
|
||
| /* |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| - Constructor functions or, briefly, constructors, are regular functions, but there's a common agreement to name them with capital letter first. | ||
| - Constructor functions should only be called using `new`. Such a call implies a creation of empty `this` at the start and returning the populated one at the end. | ||
| - Funções construtoras ou, resumidamente, construtores, são funções regulares, mas existe um acordo comum para nomeá-las com a primeira letra em maiúsculo. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| - Constructor functions or, briefly, constructors, are regular functions, but there's a common agreement to name them with capital letter first. | ||
| - Constructor functions should only be called using `new`. Such a call implies a creation of empty `this` at the start and returning the populated one at the end. | ||
| - Funções construtoras ou, resumidamente, construtores, são funções regulares, mas existe um acordo comum para nomeá-las com a primeira letra em maiúsculo. | ||
| - Funções construtoras deveriam ser chamadas apenas usando `new`. Tal chamada implica a criação de um `this` vazio no começo e retornando o completo ao final. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
"...no começo e o retornando -o- completo ao final."
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Nós podemos usar funções construtoras para fazer diversos objetos iguais. | ||
|
|
||
| JavaScript provides constructor functions for many built-in language objects: like `Date` for dates, `Set` for sets and others that we plan to study. | ||
| JavaScript fornece funções construtoras para muitos objetos de linguagem internos: como `Date` para datas, `Set` para armazenamento e outros que nós planejamos estudar. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Set para
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Nesse capítulo nós cobrimos apenas o básico sobre objetos e construtores. Eles são essenciais para aprender mais sobre tipos de dados e funções nos próximos capítulos. | ||
|
|
||
| After we learn that, we return to objects and cover them in-depth in the chapters <info:prototypes> and <info:classes>. | ||
| Depois que aprendemos isto, nós voltamos para os objetos e os cobrimos a fundo nos capítulos <info:prototypes> e <info:classes>. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Please make the requested changes. After it, add a comment "/done". |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.