Skip to content

Commit ca791b2

Browse files
committed
Fourth round of chapter one translation
1 parent e1e2acd commit ca791b2

File tree

1 file changed

+83
-80
lines changed

1 file changed

+83
-80
lines changed

01_valores.md

Lines changed: 83 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,9 @@ posición. El ejemplo anterior produce "_la mitad de 100 es 50_".
352352

353353
{{index operator, "typeof operator", type}}
354354

355-
Not all operators are symbols. Some are written as words. One example
356-
is the `typeof` operator, which produces a string value naming the
357-
type of the value you give it.
355+
No todo los operadores son simbolos. Algunos se escriben como palabras.
356+
Un ejemplo es el operador `typeof`, que produce un string con el nombre
357+
del tipo de valor que le mandemos.
358358

359359
```
360360
console.log(typeof 4.5)
@@ -367,17 +367,17 @@ console.log(typeof "x")
367367

368368
{{id "console.log"}}
369369

370-
We will use `console.log` in example code to indicate that we want to
371-
see the result of evaluating something. More about that in the [next
372-
chapter](program_structure).
370+
Usaremos `console.log` en los ejemplos de codigo para indicar que
371+
lo que queremos es ver es el resultado de alguna evaluación.
372+
Expandiremos en esto en el [proximo capitulo](program_structure).
373373

374374
{{index negation, "- operator", "binary operator", "unary operator"}}
375375

376-
The other operators we saw all operated on two values, but `typeof`
377-
takes only one. Operators that use two values are called _binary_
378-
operators, while those that take one are called _unary_ operators. The
379-
minus operator can be used both as a binary operator and as a unary
380-
operator.
376+
Los operadores que hemos visto hasta ahora todos operaban en does valores,
377+
pero `typeof` sola opera con un valor. Los operadores que usan dos valores
378+
son llamados _binarios_, mientras que aquellos operadores que usan uno son
379+
llamados _unarios_. El operador menos puede ser usado como operador binario
380+
o como operador unario.
381381

382382
```
383383
console.log(- (10 - 2))
@@ -388,16 +388,16 @@ console.log(- (10 - 2))
388388

389389
{{index Boolean, operator, true, false, bit}}
390390

391-
It is often useful to have a value that distinguishes between only two
392-
possibilities, like "yes" and "no" or "on" and "off". For this
393-
purpose, JavaScript has a _Boolean_ type, which has just two values:
394-
true and false, which are written as those words.
391+
Es frecuentemente util tener un valor que distigue entre solo dos
392+
posibilidades, como "si", y "no", o "encendido" y "apagado". Para este
393+
proposito, JavaScript tiene el tipo _Boolean_, que tiene dos valores:
394+
verdadero (`true`) y falso (`false`) que se escriben de la misma forma.
395395

396396
### Comparison
397397

398398
{{index comparison}}
399399

400-
Here is one way to produce Boolean values:
400+
Aqui se muestra una forma de producir valores Booleanos:
401401

402402
```
403403
console.log(3 > 2)
@@ -408,12 +408,12 @@ console.log(3 < 2)
408408

409409
{{index [comparison, "of numbers"], "> operator", "< operator", "greater than", "less than"}}
410410

411-
The `>` and `<` signs are the traditional symbols for "is greater
412-
than" and "is less than", respectively. They are binary operators.
413-
Applying them results in a Boolean value that indicates whether they
414-
hold true in this case.
411+
Los signos `>` y `<` son tradicionalmente symbolos para "mayor que"
412+
y "menor que", respectivamente. Ambos son operadores binarios.
413+
Aplicarlos resulta en un valor Boolean que indica si la condicion
414+
se cumple.
415415

416-
Strings can be compared in the same way.
416+
Los Strings pueden ser comparados de la misma forma.
417417

418418
```
419419
console.log("Aardvark" < "Zoroaster")
@@ -422,27 +422,29 @@ console.log("Aardvark" < "Zoroaster")
422422

423423
{{index [comparison, "of strings"]}}
424424

425-
The way strings are ordered is roughly alphabetic, but not really what
426-
you'd expect to see in a dictionary: uppercase letters are always
427-
"less" than lowercase ones, so `"Z" < "a"`, and non-alphabetic
428-
characters (!, -, and so on) are also included in the ordering. When
429-
comparing strings, JavaScript goes over the characters from left to
430-
right, comparing the ((Unicode)) codes one by one.
425+
La forma en la que los strings son ordenados, es aproximadamente alfabetica,
426+
aunque no realmente de la misma forma que esperaríamos ver en un diccionario:
427+
letras mayusculas son siempre "menores que" letras minusculas, así que `"Z" < "a"`,
428+
y caracteres no alfabéticos como `!`, `-`, y demas, son tambíen incluidos en el
429+
ordenamiento. Cuando comparamos strings, JavaScript evalua los caracteres
430+
de izquierda a derecha, comparando los codicos ((Unicode)) uno por uno.
431431

432432
{{index equality, ">= operator", "<= operator", "== operator", "!= operator"}}
433433

434-
Other similar operators are `>=` (greater than or equal to), `<=`
435-
(less than or equal to), `==` (equal to), and `!=` (not equal to).
434+
Otros operadores similares son `>=` (mayor o igual que), `<=` (menor y igual que),
435+
`==` (igual a), y `!=` (no igual a).
436436

437437
```
438-
console.log("Itchy" != "Scratchy")
438+
console.log("Irritante" != "Arañoso")
439439
// → true
440-
console.log("Apple" == "Orange")
440+
console.log("Manzana" == "Naranja")
441441
// → false
442442
```
443443

444444
{{index [comparison, "of NaN"], NaN}}
445445

446+
Solo hay un valor en JavaScript que no es igual a si mismo, y este es
447+
`NaN` ("no es numero").
446448
There is only one value in JavaScript that is not equal to itself, and
447449
that is `NaN` ("not a number").
448450

@@ -451,22 +453,22 @@ console.log(NaN == NaN)
451453
// → false
452454
```
453455

454-
`NaN` is supposed to denote the result of a nonsensical computation,
455-
and as such, it isn't equal to the result of any _other_ nonsensical
456-
computations.
456+
`NaN` esta supuesto a denotar el resultado de una computación sin sentido,
457+
y como tal, no es igual al resultado de ninguna _otra_ comptacion sin sentido.
457458

458459
### Logical operators
459460

460461
{{index reasoning, "logical operators"}}
461462

462-
There are also some operations that can be applied to Boolean values
463-
themselves. JavaScript supports three logical operators: _and_, _or_,
464-
and _not_. These can be used to "reason" about Booleans.
463+
Tambien existen algunas operaciones que pueden ser aplicadas a valores
464+
Boolean. JavaScript soporta tres operadores logicos: _and_, _or_, y _not_.
465+
Estos pueden ser usados para "razonar" balores Boolean.
465466

466467
{{index "&& operator", "logical and"}}
467468

468-
The `&&` operator represents logical _and_. It is a binary operator,
469-
and its result is true only if both the values given to it are true.
469+
El operador `&&` representa el operador logico _and_. Es un operador
470+
binario, y su resultado es verdadero solo si ambos de los valores
471+
dados son verdaderos.
470472

471473
```
472474
console.log(true && false)
@@ -477,8 +479,8 @@ console.log(true && true)
477479

478480
{{index "|| operator", "logical or"}}
479481

480-
The `||` operator denotes logical _or_. It produces true if either of
481-
the values given to it is true.
482+
El operador `||` representa el operador logico _or_. Lo que produce es
483+
verdadero si cualquiera de los valores dados es verdadero.
482484

483485
```
484486
console.log(false || true)
@@ -489,29 +491,30 @@ console.log(false || false)
489491

490492
{{index negation, "! operator"}}
491493

492-
_Not_ is written as an exclamation mark (`!`). It is a unary operator
493-
that flips the value given to it—`!true` produces `false` and `!false`
494-
gives `true`.
494+
_Not_ se escribe como un signo de exclamación (`!`). Es un operador
495+
unario que voltea el valor dado-`!true` produce `false` y `!false`
496+
produce `true`.
495497

496498
{{index precedence}}
497499

498-
When mixing these Boolean operators with arithmetic and other
499-
operators, it is not always obvious when parentheses are needed. In
500-
practice, you can usually get by with knowing that of the operators we
501-
have seen so far, `||` has the lowest precedence, then comes `&&`,
502-
then the comparison operators (`>`, `==`, and so on), and then the
503-
rest. This order has been chosen such that, in typical expressions
504-
like the following one, as few parentheses as possible are necessary:
500+
Cuando estos operadores Boolean son mezclados con otro tipo de
501+
operadores, no es siempre obvio cuando son necesarios los parentesis.
502+
En la practiva, puedes usualmente manejarte bien sabiendo que de
503+
los operadores que hemos visto hasta ahora, `||` tiene menor precedencia,
504+
luego le sigue `&&`, luego le siguen los operadores de comparación
505+
(`>`, `==`, y demas), y luego el resto. Este orden ha sido determinado para
506+
que en expresiones como la siguiente, la menos cantidad de parentesis es
507+
requerida:
505508

506509
```
507510
1 + 1 == 2 && 10 * 10 > 50
508511
```
509512

510513
{{index "conditional execution", "ternary operator", "?: operator", "conditional operator", "colon character", "question mark"}}
511514

512-
The last logical operator I will discuss is not unary, not binary, but
513-
_ternary_, operating on three values. It is written with a question
514-
mark and a colon, like this:
515+
El ultimo operador logico que discutiremos no es unario, tampoco binario,
516+
pero ternario, esto es, que opera en tres valores. Es escrito con un
517+
signo de interrocación y dos puntos, de esta forma:
515518

516519
```
517520
console.log(true ? 1 : 2);
@@ -520,36 +523,36 @@ console.log(false ? 1 : 2);
520523
// → 2
521524
```
522525

523-
This one is called the _conditional_ operator (or sometimes just
524-
_ternary_ operator since it is the only such operator in the
525-
language). The value on the left of the question mark "picks" which of
526-
the other two values will come out. When it is true, it chooses the
527-
middle value, and when it is false, the value on the right.
526+
Este es llamado el operador _condicional_ (o algunas veces simplemente
527+
operador _ternario_ ya que solo existe uno de este tipo). El valor a la
528+
izquierda del signo de interrogación "decide" cual de los otros dos valores
529+
sera retornado. Cuando es verdadero, elije el valor de en medio, y cuando es
530+
falso, el valor de la derecha.
528531

529532
## Empty values
530533

531534
{{index undefined, null}}
532535

533-
There are two special values, written `null` and `undefined`, that are
534-
used to denote the absence of a _meaningful_ value. They are
535-
themselves values, but they carry no information.
536+
Existen dos valores especiales, escritos `null` y `undefined`, que son
537+
usados para denotar la ausencia de un valor _significativo_. Son en si mismo
538+
valores, pero no traen consigo información.
536539

537-
Many operations in the language that don't produce a meaningful value
538-
(you'll see some later) yield `undefined` simply because they have to
539-
yield _some_ value.
540+
Muchos de los operadores en el lenguage que no producen un valor significativo
541+
(veremos algunos mas adelante), producen `undefined` simplemente porque tienen
542+
que producir _algun_ valor.
540543

541-
The difference in meaning between `undefined` and `null` is an accident
542-
of JavaScript's design, and it doesn't matter most of the time. In the cases
543-
where you actually have to concern yourself with these values, I
544-
recommend treating them as mostly interchangeable.
544+
La diferencia en significado entre `undefined`y `null`es un accidente del
545+
diseño de JavaScript, y realmente no importa la mayor parte del tiempo.
546+
En los casos donde realmente tendríamos que preocuparnos por estos valores,
547+
mayormente recomiendo tratarlos como intercambiables.
545548

546549
## Automatic type conversion
547550

548551
{{index NaN, "type coercion"}}
549552

550-
In the introduction, I mentioned that JavaScript goes out of its way
551-
to accept almost any program you give it, even programs that do odd
552-
things. This is nicely demonstrated by the following expressions:
553+
En la introducción, he mencionado que JavaScript trata mucho de aceptar
554+
casi cualquier programa que le demos, aún programas que hacen cosas
555+
extrañas. Esto es bien demostrado por la proxima expresión:
553556

554557
```
555558
console.log(8 * null)
@@ -566,14 +569,14 @@ console.log(false == 0)
566569

567570
{{index "+ operator", arithmetic, "* operator", "- operator"}}
568571

569-
When an operator is applied to the "wrong" type of value, JavaScript
570-
will quietly convert that value to the type it needs, using a set of
571-
rules that often aren't what you want or expect. This is called
572-
_((type coercion))_. The `null` in the first expression becomes `0`,
573-
and the `"5"` in the second expression becomes `5` (from string to
574-
number). Yet in the third expression, `+` tries string concatenation
575-
before numeric addition, so the `1` is converted to `"1"` (from number
576-
to string).
572+
Cuando un operador es aplicado el tipo de valor "incorrecto", JvasScript
573+
calladamente convertirá ese valor al tipo que necesita, utilizando una
574+
seria de reglas que frecuentemente no dan el resultado que quisieras
575+
o esperarías. Esto es llamado _((coherción de tipo))_. El `null`
576+
en la primera expresión se torna `0`, y el `"5"`en la segunda expresión
577+
se torna `5` (de string a numero). Sin embargo, en la tercera expresión,
578+
`+` trata concatenación de string antes de adicion numerica, entonces
579+
el `1` es convertido a `"1"` (de numero a string)
577580

578581
{{index "type coercion", [number, "conversion to"]}}
579582

0 commit comments

Comments
 (0)