Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pt-br: Format /web/javascript using Prettier (part 5) #14829

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ String.prototype.trimRight.name === "trimEnd";
O exemplo a seguir mostra a _string_ em caixa baixa `' foo'`:

```js
var str = ' foo ';
var str = " foo ";

console.log(str.length); // retorna 8

str = str.trimEnd();
console.log(str.length); // retorna 6
console.log(str); // retorna ' foo'
console.log(str); // retorna ' foo'
```

## Especificações

| Especificação |
| ---------------------------------------------------------------------------------------------------------------- |
| Especificação |
| ------------------------------------------------------------------------------------ |
| {{SpecName('ESDraft', '#sec-string.prototype.trimend', 'String.prototype.trimEnd')}} |

## Compatibilidade com navegadores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,22 @@ String.prototype.trimLeft.name === "trimStart";
```js
//https://github.com/FabioVergani/js-Polyfill_String-trimStart

(function(w){
var String=w.String, Proto=String.prototype;

(function(o,p){
if(p in o?o[p]?false:true:true){
var r=/^\s+/;
o[p]=o.trimLeft||function(){
return this.replace(r,'')
}
}
})(Proto,'trimStart');

(function (w) {
var String = w.String,
Proto = String.prototype;

(function (o, p) {
if (p in o ? (o[p] ? false : true) : true) {
var r = /^\s+/;
o[p] =
o.trimLeft ||
function () {
return this.replace(r, "");
};
}
})(Proto, "trimStart");
})(window);


/*
ES6:
(w=>{
Expand All @@ -77,19 +78,19 @@ ES6:
O seguinte exemplo mostra uma _string_ em caixa baixa `'foo '`:

```js
var str = ' foo ';
var str = " foo ";

console.log(str.length); // retorna 8

str = str.trimStart();
console.log(str.length); // retorna 5
console.log(str); // retorna 'foo '
console.log(str); // retorna 'foo '
```

## Especificações

| Especificação |
| ------------------------------------------------------------------------------------------------------------------------ |
| Especificação |
| ----------------------------------------------------------------------------------------- |
| {{SpecName('ESDraft', '#sec-string.prototype.trimstart', ' String.prototype.trimStart')}} |

## Compatibilidade com navegadores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ Esse método é normalmente chamado internamente pelo JavaScript e não fica exp
### Usando `valueOf()`

```js
var x = new String('Olá, mundo');
var x = new String("Olá, mundo");
console.log(x.valueOf()); // retorna 'Olá, mundo'
```

## Especificações

| Especificação | Status | Comentário |
| ---------------------------------------------------------------------------------------------------------------- | ---------------------------- | ------------------------------------------------- |
| {{SpecName('ES1')}} | {{Spec2('ES1')}} | Definição inicial implementada no JavaScript 1.1. |
| {{SpecName('ES5.1', '#sec-15.5.4.3', 'String.prototype.valueOf')}} | {{Spec2('ES5.1')}} | |
| {{SpecName('ES6', '#sec-string.prototype.valueof', 'String.prototype.valueOf')}} | {{Spec2('ES6')}} | |
| Especificação | Status | Comentário |
| ------------------------------------------------------------------------------------ | -------------------- | ------------------------------------------------- |
| {{SpecName('ES1')}} | {{Spec2('ES1')}} | Definição inicial implementada no JavaScript 1.1. |
| {{SpecName('ES5.1', '#sec-15.5.4.3', 'String.prototype.valueOf')}} | {{Spec2('ES5.1')}} | |
| {{SpecName('ES6', '#sec-string.prototype.valueof', 'String.prototype.valueOf')}} | {{Spec2('ES6')}} | |
| {{SpecName('ESDraft', '#sec-string.prototype.valueof', 'String.prototype.valueOf')}} | {{Spec2('ESDraft')}} | |

## Compatibilidade com navegadores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ Você consegue definir seu próprio iterável assíncrono configurando a proprie

```js
const myAsyncIterable = {
async* [Symbol.asyncIterator]() {
yield "hello";
yield "async";
yield "iteration!";
}
async *[Symbol.asyncIterator]() {
yield "hello";
yield "async";
yield "iteration!";
},
};

(async () => {
for await (const x of myAsyncIterable) {
console.log(x);
// resultado esperado:
// "hello"
// "async"
// "iteration!"
}
for await (const x of myAsyncIterable) {
console.log(x);
// resultado esperado:
// "hello"
// "async"
// "iteration!"
}
})();
```

Expand All @@ -47,8 +47,8 @@ Não há atualmente objetos Javascript built-in que tenha a chave `[Symbol.async

## Especificações

| Especificação |
| ---------------------------------------------------------------------------------------------------- |
| Especificação |
| ---------------------------------------------------------------------------- |
| {{SpecName('ESDraft', '#sec-symbol.asynciterator', 'Symbol.asyncIterator')}} |

## Compatibilidade com navegadores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ A propriedade leitura somente **`description`** é uma string que retorna a desc
### Usando descrição

```js
Symbol('desc').toString(); // "Symbol(desc)"
Symbol('desc').description; // "desc"
Symbol('').description; // ""
Symbol().description; // undefined
Symbol("desc").toString(); // "Symbol(desc)"
Symbol("desc").description; // "desc"
Symbol("").description; // ""
Symbol().description; // undefined

// símbolos conhecidos
Symbol.iterator.toString(); // "Symbol(Symbol.iterator)"
Symbol.iterator.toString(); // "Symbol(Symbol.iterator)"
Symbol.iterator.description; // "Symbol.iterator"

// símbolos globais
Symbol.for('foo').toString(); // "Symbol(foo)"
Symbol.for('foo').description; // "foo"
Symbol.for("foo").toString(); // "Symbol(foo)"
Symbol.for("foo").description; // "foo"
```

## Especificações

| Especificação |
| -------------------------------------------------------------------------------------------------------------------------------- |
| Especificação |
| ------------------------------------------------------------------------------------------------ |
| {{SpecName("ESDraft", "#sec-symbol.prototype.description", "get Symbol.prototype.description")}} |

## Compatibilidade com navegadores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,25 @@ Você pode implementar o comportamento customizado do seu `instanceof` deste jei
```js
class MyArray {
static [Symbol.hasInstance](instance) {
return this.prototype.isPrototypeOf(instance) ||
Array.isArray(instance);
return this.prototype.isPrototypeOf(instance) || Array.isArray(instance);
}
}

console.log([] instanceof MyArray); // true
console.log(new MyArray instanceof MyArray); // true
console.log(new Image instanceof MyArray); // false
console.log(new MyArray() instanceof MyArray); // true
console.log(new Image() instanceof MyArray); // false

class MySubArray extends MyArray {}
console.log(new MySubArray instanceof MySubArray); // true
console.log(new MySubArray instanceof MyArray); // true
console.log(new MyArray instanceof MySubArray); // false
console.log(new MySubArray() instanceof MySubArray); // true
console.log(new MySubArray() instanceof MyArray); // true
console.log(new MyArray() instanceof MySubArray); // false
```

## Especificações

| Specification | Status | Comment |
| ------------------------------------------------------------------------------------------------ | ---------------------------- | ------------------- |
| {{SpecName('ES6', '#sec-symbol.hasinstance', 'Symbol.hasInstance')}} | {{Spec2('ES6')}} | Initial definition. |
| Specification | Status | Comment |
| ------------------------------------------------------------------------ | -------------------- | ------------------- |
| {{SpecName('ES6', '#sec-symbol.hasinstance', 'Symbol.hasInstance')}} | {{Spec2('ES6')}} | Initial definition. |
| {{SpecName('ESDraft', '#sec-symbol.hasinstance', 'Symbol.hasInstance')}} | {{Spec2('ESDraft')}} | |

## Compatibilidade com navegadores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ Se você realmente quiser criar um objeto empacotador de `Symbol`, você pode us

```js
var sym = Symbol("foo");
typeof sym; // "symbol"
typeof sym; // "symbol"
var symObj = Object(sym);
typeof symObj; // "object"
typeof symObj; // "object"
```

### Símbolos compartilhados no registro global de símbolo
Expand Down Expand Up @@ -117,9 +117,9 @@ Todos os símbolos herdados de {{jsxref("Symbol.prototype")}}.
O operador {{jsxref("Operators/typeof", "typeof")}} pode ajudar a identificar os símbolos.

```js
typeof Symbol() === 'symbol'
typeof Symbol('foo') === 'symbol'
typeof Symbol.iterator === 'symbol'
typeof Symbol() === "symbol";
typeof Symbol("foo") === "symbol";
typeof Symbol.iterator === "symbol";
```

### Conversões de tipos de símbolos
Expand All @@ -145,7 +145,7 @@ obj["c"] = "c";
obj.d = "d";

for (var i in obj) {
console.log(i); // logs "c" and "d"
console.log(i); // logs "c" and "d"
}
```

Expand All @@ -154,7 +154,7 @@ for (var i in obj) {
Propriedade com chave de símbolo vão ser completamente ignoradas quando usando `JSON.stringify()`:

```js
JSON.stringify({[Symbol("foo")]: "foo"});
JSON.stringify({ [Symbol("foo")]: "foo" });
// '{}'
```

Expand All @@ -166,15 +166,15 @@ Quando um objeto wrapper de um símbolo é usado como uma chave de propriedade,

```js
var sym = Symbol("foo");
var obj = {[sym]: 1};
obj[sym]; // 1
obj[Object(sym)]; // still 1
var obj = { [sym]: 1 };
obj[sym]; // 1
obj[Object(sym)]; // still 1
```

## Especificações

| Specification | Status | Comment |
| ------------------------------------------------------------------------ | ------------------------ | ------------------ |
| Specification | Status | Comment |
| ------------------------------------------------------- | ------------------- | ------------------ |
| {{SpecName('ES2015', '#sec-symbol-objects', 'Symbol')}} | {{Spec2('ES2015')}} | Definição inicial. |

## Compatibilidade com navegadores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ console.log(alphaNumeric) // Resultado: ['a', 'b', 'c', [1, 2, 3] ]
Para objetos de array semelhantes, o padrão não é espalhado. `Symbol.isConcatSpreadable`precisa ser configurado para `true` para poder conseguir um a array alinhada:

```js
let x = [1, 2, 3]
let x = [1, 2, 3];

let fakeArray = {
[Symbol.isConcatSpreadable]: true,
length: 2,
0: 'hello',
1: 'world'
}
0: "hello",
1: "world",
};

x.concat(fakeArray) // [1, 2, 3, "hello", "world"]
x.concat(fakeArray); // [1, 2, 3, "hello", "world"]
```

> **Nota:** A propriedade `length` é usada para controlar o número de propriedade dos objetos para ser adicionado. No exemplo acima, `length:2` indica que duas propriedades tem de ser adicionado.
## Especificações

| Especificação |
| -------------------------------------------------------------------------------------------------------------------- |
| Especificação |
| -------------------------------------------------------------------------------------- |
| {{SpecName('ESDraft', '#sec-symbol.isconcatspreadable', 'Symbol.isconcatspreadable')}} |

## Compatibilidade com navegadores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ Veja também [Iteration protocols](/pt-BR/docs/Web/JavaScript/Reference/Iteratio
Podemos fazer nosso próprio iterável dessa forma:

```js
var myIterable = {}
var myIterable = {};
myIterable[Symbol.iterator] = function* () {
yield 1;
yield 2;
yield 3;
yield 1;
yield 2;
yield 3;
};
[...myIterable] // [1, 2, 3]
[...myIterable]; // [1, 2, 3]
```

Ou iteráveis podem ser definidos diretamente dentro de uma classe ou um objeto usando [computed property](/pt-BR/docs/Web/JavaScript/Reference/Operators/Object_initializer#Computed_property_names):
Expand Down Expand Up @@ -75,8 +75,8 @@ nonWellFormedIterable[Symbol.iterator] = () => 1

## Especificações

| Especificação |
| ---------------------------------------------------------------------------------------- |
| Especificação |
| ------------------------------------------------------------------ |
| {{SpecName('ESDraft', '#sec-symbol.iterator', 'Symbol.iterator')}} |

## Compatibilidade com navegadores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Essa função também é usada para identificar se um objeto tem o comportamento
O seguinte código vai lançar um {{jsxref("TypeError")}}:

```js
'/bar/'.startsWith(/bar/);
"/bar/".startsWith(/bar/);

// Lança um TypeError, como /bar/ é uma expressão regular
// não Symbol.match não é modificado.
Expand All @@ -33,14 +33,14 @@ Entretanto, se você configurar `Symbol.match` para `false`, a verificação `is
```js
var re = /foo/;
re[Symbol.match] = false;
'/foo/'.startsWith(re); // true
'/baz/'.endsWith(re); // false
"/foo/".startsWith(re); // true
"/baz/".endsWith(re); // false
```

## Especificações

| Especificação |
| -------------------------------------------------------------------------------- |
| Especificação |
| ------------------------------------------------------------ |
| {{SpecName('ESDraft', '#sec-symbol.match', 'Symbol.match')}} |

## Compatibilidade com navegadores
Expand Down
Loading