From 218db1a8473957357a06dd27d24fc813abb9daa6 Mon Sep 17 00:00:00 2001
From: Azarias Boutin
Date: Thu, 13 Jun 2019 15:30:05 +0200
Subject: [PATCH 001/881] Missing console.log
Question is "what's the output" but console.log is not called
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 035ce096..8f5a893b 100644
--- a/README.md
+++ b/README.md
@@ -804,7 +804,7 @@ String.prototype.giveLydiaPizza = () => {
const name = "Lydia";
-name.giveLydiaPizza();
+console.log(name.giveLydiaPizza());
```
- A: `"Just give Lydia pizza already!"`
From 8d4a71711f4bdcd60b874d3bdb4a303f2aee13ec Mon Sep 17 00:00:00 2001
From: Azarias Boutin
Date: Thu, 13 Jun 2019 15:34:42 +0200
Subject: [PATCH 002/881] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 8f5a893b..5b742ac1 100644
--- a/README.md
+++ b/README.md
@@ -1006,7 +1006,7 @@ function sayHi() {
return (() => 0)();
}
-typeof sayHi();
+console.log(typeof sayHi());
```
- A: `"object"`
From 7254980188e4daa911d9000238c1f98bea1f5d9a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n?= <22575055+aguadotzn@users.noreply.github.com>
Date: Mon, 17 Jun 2019 16:45:34 +0200
Subject: [PATCH 003/881] Add list of languages
---
README.md | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index ad45ee46..f5bb6259 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,10 @@ From basic to advanced: test how well you know JavaScript, refresh your knowledg
The answers are in the collapsed sections below the questions, simply click on them to expand it. Good luck :heart:
-[中文版本](./README-zh_CN.md)
+---
+List of a available languages:
+* 🇨🇳[中文版本](./README-zh_CN.md)
+* 🇪🇸[Versión en español](./README-ES.md)
---
From 4f22f11bdbeeb86c3995070ba83e788750067e84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n?= <22575055+aguadotzn@users.noreply.github.com>
Date: Mon, 17 Jun 2019 17:01:33 +0200
Subject: [PATCH 004/881] First commit
---
README-ES.md | 1296 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 1296 insertions(+)
create mode 100644 README-ES.md
diff --git a/README-ES.md b/README-ES.md
new file mode 100644
index 00000000..391673e1
--- /dev/null
+++ b/README-ES.md
@@ -0,0 +1,1296 @@
+
+# Lista de preguntas (avanzadas) de JavaScript
+
+ Publico diariamente preguntas de opción múltiple en JavaScript en mi [Instagram](https://www.instagram.com/theavocoder), que también publicaré aquí!
+
+ Desde lo básico a lo avanzado: comprueba si realmente conoces _Javascript_, actualiza tus conocimientos o simplemente prepárate para tu próxima entrevista 💪
+
+ Actualizaré este repo semanalmente con nuevas preguntas. Las respuestas se encuentran en las secciones contraídas debajo de las preguntas, simplemente haz clic en ellas para expandirlas. Buena suerte ❤️
+
+---
+Lista de lenguajes disponibles:
+* 🇬🇧[English version](./README.md)
+* 🇨🇳[中文版本](./README-zh_CN.md)
+
+
+---
+
+###### 1. ¿Qué devuelve la siguiente función?
+
+```javascript
+function sayHi() {
+ console.log(name);
+ console.log(age);
+ var name = "Lydia";
+ let age = 21;
+}
+
+sayHi();
+```
+
+- A: `Lydia` y `undefined`
+- B: `Lydia` y `ReferenceError`
+- C: `ReferenceError` y `21`
+- D: `undefined` y `ReferenceError`
+
+Answer
+
+
+#### Respuesta: D
+
+Within the function, we first declare the `name` variable with the `var` keyword. This means that the variable gets hoisted (memory space is set up during the creation phase) with the default value of `undefined`, until we actually get to the line where we define the variable. We haven't defined the variable yet on the line where we try to log the `name` variable, so it still holds the value of `undefined`.
+
+Variables with the `let` keyword (and `const`) are hoisted, but unlike `var`, don't get initialized. They are not accessible before the line we declare (initialize) them. This is called the "temporal dead zone". When we try to access the variables before they are declared, JavaScript throws a `ReferenceError`.
+
+
+
+
+---
+
+###### 2. ¿Qué devuelve la siguiente función?
+
+```javascript
+for (var i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+
+for (let i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+```
+
+- A: `0 1 2` and `0 1 2`
+- B: `0 1 2` and `3 3 3`
+- C: `3 3 3` and `0 1 2`
+
+Answer
+
+
+#### Respuesta: C
+
+Because of the event queue in JavaScript, the `setTimeout` function is called _after_ the loop has been executed. Since the variable `i` in the first loop was declared using the `var` keyword, this value was global. During the loop, we incremented the value of `i` by `1` each time, using the unary operator `++`. By the time the `setTimeout` function was invoked, `i` was equal to `3` in the first example.
+
+In the second loop, the variable `i` was declared using the `let` keyword: variables declared with the `let` (and `const`) keyword are block-scoped (a block is anything between `{ }`). During each iteration, `i` will have a new value, and each value is scoped inside the loop.
+
+
+
+
+---
+
+###### 3. ¿Qué devuelve la siguiente función?
+
+```javascript
+const shape = {
+ radius: 10,
+ diameter() {
+ return this.radius * 2;
+ },
+ perimeter: () => 2 * Math.PI * this.radius
+};
+
+shape.diameter();
+shape.perimeter();
+```
+
+- A: `20` and `62.83185307179586`
+- B: `20` and `NaN`
+- C: `20` and `63`
+- D: `NaN` and `63`
+
+Answer
+
+
+#### Answer: B
+
+Note that the value of `diameter` is a regular function, whereas the value of `perimeter` is an arrow function.
+
+With arrow functions, the `this` keyword refers to its current surrounding scope, unlike regular functions! This means that when we call `perimeter`, it doesn't refer to the shape object, but to its surrounding scope (window for example).
+
+There is no value `radius` on that object, which returns `undefined`.
+
+
+
+
+---
+
+###### 4. What's the output?
+
+```javascript
++true;
+!"Lydia";
+```
+
+- A: `1` and `false`
+- B: `false` and `NaN`
+- C: `false` and `false`
+
+Answer
+
+
+#### Answer: A
+
+The unary plus tries to convert an operand to a number. `true` is `1`, and `false` is `0`.
+
+The string `'Lydia'` is a truthy value. What we're actually asking, is "is this truthy value falsy?". This returns `false`.
+
+
+
+
+---
+
+###### 5. Which one is NOT valid?
+
+```javascript
+const bird = {
+ size: "small"
+};
+
+const mouse = {
+ name: "Mickey",
+ small: true
+};
+```
+
+- A: `mouse.bird.size`
+- B: `mouse[bird.size]`
+- C: `mouse[bird["size"]]`
+- D: All of them are valid
+
+Answer
+
+
+#### Answer: A
+
+In JavaScript, all object keys are strings (unless it's a Symbol). Even though we might not _type_ them as strings, they are always converted into strings under the hood.
+
+JavaScript interprets (or unboxes) statements. When we use bracket notation, it sees the first opening bracket `[` and keeps going until it finds the closing bracket `]`. Only then, it will evaluate the statement.
+
+`mouse[bird.size]`: First it evaluates `bird.size`, which is `"small"`. `mouse["small"]` returns `true`
+
+However, with dot notation, this doesn't happen. `mouse` does not have a key called `bird`, which means that `mouse.bird` is `undefined`. Then, we ask for the `size` using dot notation: `mouse.bird.size`. Since `mouse.bird` is `undefined`, we're actually asking `undefined.size`. This isn't valid, and will throw an error similar to `Cannot read property "size" of undefined`.
+
+
+
+
+---
+
+---
+
+###### 6. What's the output?
+
+```javascript
+let c = { greeting: "Hey!" };
+let d;
+
+d = c;
+c.greeting = "Hello";
+console.log(d.greeting);
+```
+
+- A: `Hello`
+- B: `undefined`
+- C: `ReferenceError`
+- D: `TypeError`
+
+Answer
+
+
+#### Answer: A
+
+In JavaScript, all objects interact by _reference_ when setting them equal to each other.
+
+First, variable `c` holds a value to an object. Later, we assign `d` with the same reference that `c` has to the object.
+
+
+
+When you change one object, you change all of them.
+
+
+
+
+---
+
+###### 7. What's the output?
+
+```javascript
+let a = 3;
+let b = new Number(3);
+let c = 3;
+
+console.log(a == b);
+console.log(a === b);
+console.log(b === c);
+```
+
+- A: `true` `false` `true`
+- B: `false` `false` `true`
+- C: `true` `false` `false`
+- D: `false` `true` `true`
+
+Answer
+
+
+#### Answer: C
+
+`new Number()` is a built-in function constructor. Although it looks like a number, it's not really a number: it has a bunch of extra features and is an object.
+
+When we use the `==` operator, it only checks whether it has the same _value_. They both have the value of `3`, so it returns `true`.
+
+However, when we use the `===` operator, both value _and_ type should be the same. It's not: `new Number()` is not a number, it's an **object**. Both return `false.`
+
+
+
+
+---
+
+###### 8. What's the output?
+
+```javascript
+class Chameleon {
+ static colorChange(newColor) {
+ this.newColor = newColor;
+ return this.newColor;
+ }
+
+ constructor({ newColor = "green" } = {}) {
+ this.newColor = newColor;
+ }
+}
+
+const freddie = new Chameleon({ newColor: "purple" });
+freddie.colorChange("orange");
+```
+
+- A: `orange`
+- B: `purple`
+- C: `green`
+- D: `TypeError`
+
+Answer
+
+
+#### Answer: D
+
+The `colorChange` function is static. Static methods are designed to live only on the constructor in which they are created, and cannot be passed down to any children. Since `freddie` is a child, the function is not passed down, and not available on the `freddie` instance: a `TypeError` is thrown.
+
+
+
+
+---
+
+###### 9. What's the output?
+
+```javascript
+let greeting;
+greetign = {}; // Typo!
+console.log(greetign);
+```
+
+- A: `{}`
+- B: `ReferenceError: greetign is not defined`
+- C: `undefined`
+
+Answer
+
+
+#### Answer: A
+
+It logs the object, because we just created an empty object on the global object! When we mistyped `greeting` as `greetign`, the JS interpreter actually saw this as `global.greetign = {}` (or `window.greetign = {}` in a browser).
+
+In order to avoid this, we can use `"use strict"`. This makes sure that you have declared a variable before setting it equal to anything.
+
+
+
+
+---
+
+###### 10. What happens when we do this?
+
+```javascript
+function bark() {
+ console.log("Woof!");
+}
+
+bark.animal = "dog";
+```
+
+- A: Nothing, this is totally fine!
+- B: `SyntaxError`. You cannot add properties to a function this way.
+- C: `undefined`
+- D: `ReferenceError`
+
+Answer
+
+
+#### Answer: A
+
+This is possible in JavaScript, because functions are objects! (Everything besides primitive types are objects)
+
+A function is a special type of object. The code you write yourself isn't the actual function. The function is an object with properties. This property is invocable.
+
+
+
+
+---
+
+###### 11. What's the output?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const member = new Person("Lydia", "Hallie");
+Person.getFullName = function () {
+ return `${this.firstName} ${this.lastName}`;
+}
+
+console.log(member.getFullName());
+```
+
+- A: `TypeError`
+- B: `SyntaxError`
+- C: `Lydia Hallie`
+- D: `undefined` `undefined`
+
+Answer
+
+
+#### Answer: A
+
+You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all objects at once, you have to use the prototype instead. So in this case,
+
+```js
+Person.prototype.getFullName = function () {
+ return `${this.firstName} ${this.lastName}`;
+}
+```
+
+would have made `member.getFullName()` work. Why is this beneficial? Say that we added this method to the constructor itself. Maybe not every `Person` instance needed this method. This would waste a lot of memory space, since they would still have that property, which takes of memory space for each instance. Instead, if we only add it to the prototype, we just have it at one spot in memory, yet they all have access to it!
+
+
+
+
+---
+
+###### 12. What's the output?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const lydia = new Person("Lydia", "Hallie");
+const sarah = Person("Sarah", "Smith");
+
+console.log(lydia);
+console.log(sarah);
+```
+
+- A: `Person {firstName: "Lydia", lastName: "Hallie"}` and `undefined`
+- B: `Person {firstName: "Lydia", lastName: "Hallie"}` and `Person {firstName: "Sarah", lastName: "Smith"}`
+- C: `Person {firstName: "Lydia", lastName: "Hallie"}` and `{}`
+- D:`Person {firstName: "Lydia", lastName: "Hallie"}` and `ReferenceError`
+
+Answer
+
+
+#### Answer: A
+
+For `sarah`, we didn't use the `new` keyword. When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
+
+We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smith"`. What we actually did, is defining `global.firstName = 'Sarah'` and `global.lastName = 'Smith'`. `sarah` itself is left `undefined`.
+
+
+
+
+---
+
+###### 13. What are the three phases of event propagation?
+
+- A: Target > Capturing > Bubbling
+- B: Bubbling > Target > Capturing
+- C: Target > Bubbling > Capturing
+- D: Capturing > Target > Bubbling
+
+Answer
+
+
+#### Answer: D
+
+During the **capturing** phase, the event goes through the ancestor elements down to the target element. It then reaches the **target** element, and **bubbling** begins.
+
+
+
+
+
+
+---
+
+###### 14. All object have prototypes.
+
+- A: true
+- B: false
+
+Answer
+
+
+#### Answer: B
+
+All objects have prototypes, except for the **base object**. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
+
+
+
+
+---
+
+###### 15. What's the output?
+
+```javascript
+function sum(a, b) {
+ return a + b;
+}
+
+sum(1, "2");
+```
+
+- A: `NaN`
+- B: `TypeError`
+- C: `"12"`
+- D: `3`
+
+Answer
+
+
+#### Answer: C
+
+JavaScript is a **dynamically typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
+
+In this example, JavaScript converts the number `1` into a string, in order for the function to make sense and return a value. During the addition of a numeric type (`1`) and a string type (`'2'`), the number is treated as a string. We can concatenate strings like `"Hello" + "World"`, so what's happening here is `"1" + "2"` which returns `"12"`.
+
+
+
+
+---
+
+###### 16. What's the output?
+
+```javascript
+let number = 0;
+console.log(number++);
+console.log(++number);
+console.log(number);
+```
+
+- A: `1` `1` `2`
+- B: `1` `2` `2`
+- C: `0` `2` `2`
+- D: `0` `1` `2`
+
+Answer
+
+
+#### Answer: C
+
+The **postfix** unary operator `++`:
+
+1. Returns the value (this returns `0`)
+2. Increments the value (number is now `1`)
+
+The **prefix** unary operator `++`:
+
+1. Increments the value (number is now `2`)
+2. Returns the value (this returns `2`)
+
+This returns `0 2 2`.
+
+
+
+
+---
+
+###### 17. What's the output?
+
+```javascript
+function getPersonInfo(one, two, three) {
+ console.log(one);
+ console.log(two);
+ console.log(three);
+}
+
+const person = "Lydia";
+const age = 21;
+
+getPersonInfo`${person} is ${age} years old`;
+```
+
+- A: `"Lydia"` `21` `["", " is ", " years old"]`
+- B: `["", " is ", " years old"]` `"Lydia"` `21`
+- C: `"Lydia"` `["", " is ", " years old"]` `21`
+
+Answer
+
+
+#### Answer: B
+
+If you use tagged template literals, the value of the first argument is always an array of the string values. The remaining arguments get the values of the passed expressions!
+
+
+
+
+---
+
+###### 18. What's the output?
+
+```javascript
+function checkAge(data) {
+ if (data === { age: 18 }) {
+ console.log("You are an adult!");
+ } else if (data == { age: 18 }) {
+ console.log("You are still an adult.");
+ } else {
+ console.log(`Hmm.. You don't have an age I guess`);
+ }
+}
+
+checkAge({ age: 18 });
+```
+
+- A: `You are an adult!`
+- B: `You are still an adult.`
+- C: `Hmm.. You don't have an age I guess`
+
+Answer
+
+
+#### Answer: C
+
+When testing equality, primitives are compared by their _value_, while objects are compared by their _reference_. JavaScript checks if the objects have a reference to the same location in memory.
+
+The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
+
+This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }` return `false`.
+
+
+
+
+---
+
+###### 19. What's the output?
+
+```javascript
+function getAge(...args) {
+ console.log(typeof args);
+}
+
+getAge(21);
+```
+
+- A: `"number"`
+- B: `"array"`
+- C: `"object"`
+- D: `"NaN"`
+
+Answer
+
+
+#### Answer: C
+
+The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
+
+
+
+
+---
+
+###### 20. What's the output?
+
+```javascript
+function getAge() {
+ "use strict";
+ age = 21;
+ console.log(age);
+}
+
+getAge();
+```
+
+- A: `21`
+- B: `undefined`
+- C: `ReferenceError`
+- D: `TypeError`
+
+Answer
+
+
+#### Answer: C
+
+With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. If we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
+
+
+
+
+---
+
+###### 21. What's value of `sum`?
+
+```javascript
+const sum = eval("10*10+5");
+```
+
+- A: `105`
+- B: `"105"`
+- C: `TypeError`
+- D: `"10*10+5"`
+
+Answer
+
+
+#### Answer: A
+
+`eval` evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is `10 * 10 + 5`. This returns the number `105`.
+
+
+
+
+---
+
+###### 22. How long is cool_secret accessible?
+
+```javascript
+sessionStorage.setItem("cool_secret", 123);
+```
+
+- A: Forever, the data doesn't get lost.
+- B: When the user closes the tab.
+- C: When the user closes the entire browser, not only the tab.
+- D: When the user shuts off their computer.
+
+Answer
+
+
+#### Answer: B
+
+The data stored in `sessionStorage` is removed after closing the _tab_.
+
+If you used `localStorage`, the data would've been there forever, unless for example `localStorage.clear()` is invoked.
+
+
+
+
+---
+
+###### 23. What's the output?
+
+```javascript
+var num = 8;
+var num = 10;
+
+console.log(num);
+```
+
+- A: `8`
+- B: `10`
+- C: `SyntaxError`
+- D: `ReferenceError`
+
+Answer
+
+
+#### Answer: B
+
+With the `var` keyword, you can declare multiple variables with the same name. The variable will then hold the latest value.
+
+You cannot do this with `let` or `const` since they're block-scoped.
+
+
+
+
+---
+
+###### 24. What's the output?
+
+```javascript
+const obj = { 1: "a", 2: "b", 3: "c" };
+const set = new Set([1, 2, 3, 4, 5]);
+
+obj.hasOwnProperty("1");
+obj.hasOwnProperty(1);
+set.has("1");
+set.has(1);
+```
+
+- A: `false` `true` `false` `true`
+- B: `false` `true` `true` `true`
+- C: `true` `true` `false` `true`
+- D: `true` `true` `true` `true`
+
+Answer
+
+
+#### Answer: C
+
+All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
+
+It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')` returns `false`. It has the numeric type `1`, `set.has(1)` returns `true`.
+
+
+
+
+---
+
+###### 25. What's the output?
+
+```javascript
+const obj = { a: "one", b: "two", a: "three" };
+console.log(obj);
+```
+
+- A: `{ a: "one", b: "two" }`
+- B: `{ b: "two", a: "three" }`
+- C: `{ a: "three", b: "two" }`
+- D: `SyntaxError`
+
+Answer
+
+
+#### Answer: C
+
+If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
+
+
+
+
+---
+
+###### 26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
+
+- A: true
+- B: false
+- C: it depends
+
+Answer
+
+
+#### Answer: A
+
+The base execution context is the global execution context: it's what's accessible everywhere in your code.
+
+
+
+
+---
+
+###### 27. What's the output?
+
+```javascript
+for (let i = 1; i < 5; i++) {
+ if (i === 3) continue;
+ console.log(i);
+}
+```
+
+- A: `1` `2`
+- B: `1` `2` `3`
+- C: `1` `2` `4`
+- D: `1` `3` `4`
+
+Answer
+
+
+#### Answer: C
+
+The `continue` statement skips an iteration if a certain condition returns `true`.
+
+
+
+
+---
+
+###### 28. What's the output?
+
+```javascript
+String.prototype.giveLydiaPizza = () => {
+ return "Just give Lydia pizza already!";
+};
+
+const name = "Lydia";
+
+name.giveLydiaPizza();
+```
+
+- A: `"Just give Lydia pizza already!"`
+- B: `TypeError: not a function`
+- C: `SyntaxError`
+- D: `undefined`
+
+Answer
+
+
+#### Answer: A
+
+`String` is a built-in constructor, which we can add properties to. I just added a method to its prototype. Primitive strings are automatically converted into a string object, generated by the string prototype function. So, all strings (string objects) have access to that method!
+
+
+
+
+---
+
+###### 29. What's the output?
+
+```javascript
+const a = {};
+const b = { key: "b" };
+const c = { key: "c" };
+
+a[b] = 123;
+a[c] = 456;
+
+console.log(a[b]);
+```
+
+- A: `123`
+- B: `456`
+- C: `undefined`
+- D: `ReferenceError`
+
+Answer
+
+
+#### Answer: B
+
+Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`.
+
+However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
+
+Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to `456`, so it returns `456`.
+
+
+
+
+---
+
+###### 30. What's the output?
+
+```javascript
+const foo = () => console.log("First");
+const bar = () => setTimeout(() => console.log("Second"));
+const baz = () => console.log("Third");
+
+bar();
+foo();
+baz();
+```
+
+- A: `First` `Second` `Third`
+- B: `First` `Third` `Second`
+- C: `Second` `First` `Third`
+- D: `Second` `Third` `First`
+
+Answer
+
+
+#### Answer: B
+
+We have a `setTimeout` function and invoked it first. Yet, it was logged last.
+
+This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
+
+After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
+
+
+
+Now, `foo` gets invoked, and `"First"` is being logged.
+
+
+
+`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged.
+
+
+
+The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_.
+
+
+
+This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
+
+
+
+`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack.
+
+
+
+
+---
+
+###### 31. What is the event.target when clicking the button?
+
+```html
+
+```
+
+- A: Outer `div`
+- B: Inner `div`
+- C: `button`
+- D: An array of all nested elements.
+
+Answer
+
+
+#### Answer: C
+
+The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+
+
+
+
+---
+
+###### 32. When you click the paragraph, what's the logged output?
+
+```html
+
+```
+
+- A: `p` `div`
+- B: `div` `p`
+- C: `p`
+- D: `div`
+
+Answer
+
+
+#### Answer: A
+
+If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
+
+
+
+
+---
+
+###### 33. What's the output?
+
+```javascript
+const person = { name: "Lydia" };
+
+function sayHi(age) {
+ console.log(`${this.name} is ${age}`);
+}
+
+sayHi.call(person, 21);
+sayHi.bind(person, 21);
+```
+
+- A: `undefined is 21` `Lydia is 21`
+- B: `function` `function`
+- C: `Lydia is 21` `Lydia is 21`
+- D: `Lydia is 21` `function`
+
+Answer
+
+
+#### Answer: D
+
+With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
+
+`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
+
+
+
+
+---
+
+###### 34. What's the output?
+
+```javascript
+function sayHi() {
+ return (() => 0)();
+}
+
+typeof sayHi();
+```
+
+- A: `"object"`
+- B: `"number"`
+- C: `"function"`
+- D: `"undefined"`
+
+Answer
+
+
+#### Answer: B
+
+The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+
+FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+
+
+
+
+---
+
+###### 35. Which of these values are falsy?
+
+```javascript
+0;
+new Number(0);
+("");
+(" ");
+new Boolean(false);
+undefined;
+```
+
+- A: `0`, `''`, `undefined`
+- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
+- C: `0`, `''`, `new Boolean(false)`, `undefined`
+- D: All of them are falsy
+
+Answer
+
+
+#### Answer: A
+
+There are only six falsy values:
+
+- `undefined`
+- `null`
+- `NaN`
+- `0`
+- `''` (empty string)
+- `false`
+
+Function constructors, like `new Number` and `new Boolean` are truthy.
+
+
+
+
+---
+
+###### 36. What's the output?
+
+```javascript
+console.log(typeof typeof 1);
+```
+
+- A: `"number"`
+- B: `"string"`
+- C: `"object"`
+- D: `"undefined"`
+
+Answer
+
+
+#### Answer: B
+
+`typeof 1` returns `"number"`.
+`typeof "number"` returns `"string"`
+
+
+
+
+---
+
+###### 37. What's the output?
+
+```javascript
+const numbers = [1, 2, 3];
+numbers[10] = 11;
+console.log(numbers);
+```
+
+- A: `[1, 2, 3, 7 x null, 11]`
+- B: `[1, 2, 3, 11]`
+- C: `[1, 2, 3, 7 x empty, 11]`
+- D: `SyntaxError`
+
+Answer
+
+
+#### Answer: C
+
+When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like:
+
+`[1, 2, 3, 7 x empty, 11]`
+
+depending on where you run it (it's different for every browser, node, etc.)
+
+
+
+
+---
+
+###### 38. What's the output?
+
+```javascript
+(() => {
+ let x, y;
+ try {
+ throw new Error();
+ } catch (x) {
+ (x = 1), (y = 2);
+ console.log(x);
+ }
+ console.log(x);
+ console.log(y);
+})();
+```
+
+- A: `1` `undefined` `2`
+- B: `undefined` `undefined` `undefined`
+- C: `1` `1` `2`
+- D: `1` `undefined` `undefined`
+
+Answer
+
+
+#### Answer: A
+
+The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
+
+Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+
+Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+
+
+
+
+---
+
+###### 39. Everything in JavaScript is either a...
+
+- A: primitive or object
+- B: function or object
+- C: trick question! only objects
+- D: number or object
+
+Answer
+
+
+#### Answer: A
+
+JavaScript only has primitive types and objects.
+
+Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+
+What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+
+
+
+
+---
+
+###### 40. What's the output?
+
+```javascript
+[[0, 1], [2, 3]].reduce(
+ (acc, cur) => {
+ return acc.concat(cur);
+ },
+ [1, 2]
+);
+```
+
+- A: `[0, 1, 2, 3, 1, 2]`
+- B: `[6, 1, 2]`
+- C: `[1, 2, 0, 1, 2, 3]`
+- D: `[1, 2, 6]`
+
+Answer
+
+
+#### Answer: C
+
+`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
+
+Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
+
+
+
+
+---
+
+###### 41. What's the output?
+
+```javascript
+!!null;
+!!"";
+!!1;
+```
+
+- A: `false` `true` `false`
+- B: `false` `false` `true`
+- C: `false` `true` `true`
+- D: `true` `true` `false`
+
+Answer
+
+
+#### Answer: B
+
+`null` is falsy. `!null` returns `true`. `!true` returns `false`.
+
+`""` is falsy. `!""` returns `true`. `!true` returns `false`.
+
+`1` is truthy. `!1` returns `false`. `!false` returns `true`.
+
+
+
+
+---
+
+###### 42. What does the `setInterval` method return?
+
+```javascript
+setInterval(() => console.log("Hi"), 1000);
+```
+
+- A: a unique id
+- B: the amount of milliseconds specified
+- C: the passed function
+- D: `undefined`
+
+Answer
+
+
+#### Answer: A
+
+It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function.
+
+
+
+
+---
+
+###### 43. What does this return?
+
+```javascript
+[..."Lydia"];
+```
+
+- A: `["L", "y", "d", "i", "a"]`
+- B: `["Lydia"]`
+- C: `[[], "Lydia"]`
+- D: `[["L", "y", "d", "i", "a"]]`
+
+Answer
+
+
+#### Answer: A
+
+A string is an iterable. The spread operator maps every character of an iterable to one element.
+
+
+
From 11d7224c7c7111c1c28ca5b8927e7ef915a2cee0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n?= <22575055+aguadotzn@users.noreply.github.com>
Date: Tue, 18 Jun 2019 16:10:40 +0200
Subject: [PATCH 005/881] Questions 1 to 10.
---
README-ES.md | 131 +++++++++++++++++++++++++--------------------------
1 file changed, 65 insertions(+), 66 deletions(-)
diff --git a/README-ES.md b/README-ES.md
index 391673e1..a1f667c6 100644
--- a/README-ES.md
+++ b/README-ES.md
@@ -33,15 +33,14 @@ sayHi();
- C: `ReferenceError` y `21`
- D: `undefined` y `ReferenceError`
-Answer
+Solución
-#### Respuesta: D
-
-Within the function, we first declare the `name` variable with the `var` keyword. This means that the variable gets hoisted (memory space is set up during the creation phase) with the default value of `undefined`, until we actually get to the line where we define the variable. We haven't defined the variable yet on the line where we try to log the `name` variable, so it still holds the value of `undefined`.
+#### Respuesta Correcta: D
-Variables with the `let` keyword (and `const`) are hoisted, but unlike `var`, don't get initialized. They are not accessible before the line we declare (initialize) them. This is called the "temporal dead zone". When we try to access the variables before they are declared, JavaScript throws a `ReferenceError`.
+Dentro de la función, primero declaramos la variable `name` con la palabra reservada ` var`. Esto significa que la variable se _eleva_ (el espacio de memoria se configura durante la fase de creación. Hace referencia al termino [hoisting](https://developer.mozilla.org/es/docs/Glossary/Hoisting)) con el valor predeterminado de `indefinido`, hasta que realmente llegamos a la línea donde definimos la variable. Aún no hemos definido la variable en la línea donde intentamos registrar la variable `name`, por lo que aún mantiene el valor de` undefined`.
+Las variables con la palabra clave `let` (y` const`) se _elevan_, pero a diferencia de `var`, no se inicializa . No son accesibles antes de la línea que los declaramos (inicializamos). Esto se llama la ["zona muerta temporal"](https://wesbos.com/temporal-dead-zone/). Cuando intentamos acceder a las variables antes de que se declaren, JavaScript lanza un `ReferenceError`
@@ -59,18 +58,18 @@ for (let i = 0; i < 3; i++) {
}
```
-- A: `0 1 2` and `0 1 2`
-- B: `0 1 2` and `3 3 3`
-- C: `3 3 3` and `0 1 2`
+- A: `0 1 2` y `0 1 2`
+- B: `0 1 2` y `3 3 3`
+- C: `3 3 3` y `0 1 2`
-Answer
+Solución
-#### Respuesta: C
+#### Respuesta Correcta: C
-Because of the event queue in JavaScript, the `setTimeout` function is called _after_ the loop has been executed. Since the variable `i` in the first loop was declared using the `var` keyword, this value was global. During the loop, we incremented the value of `i` by `1` each time, using the unary operator `++`. By the time the `setTimeout` function was invoked, `i` was equal to `3` in the first example.
+Debido a la cola de eventos en JavaScript, la función `setTimeout` se llama una vez el ciclo se ha ejecutado. Dado que la variable `i` en el primer bucle se declaró utilizando la palabra reservada ` var`, este valor es global. Durante el bucle, incrementamos el valor de `i` en` 1` cada vez, utilizando el operador unario `++`. Cuando se invocó la función `setTimeout`,` i` era igual a `3` en el primer ejemplo.
-In the second loop, the variable `i` was declared using the `let` keyword: variables declared with the `let` (and `const`) keyword are block-scoped (a block is anything between `{ }`). During each iteration, `i` will have a new value, and each value is scoped inside the loop.
+En el segundo bucle, la variable `i` se declaró utilizando la palabra reservada` let`: las variables declaradas con la palabra reservada `let` (y` const`) tienen un ámbito de bloque (un bloque es lo que se encuentra entre `{}`). Durante cada iteración, `i` tendrá un nuevo valor, y cada valor se encuentra dentro del bucle.
@@ -92,53 +91,53 @@ shape.diameter();
shape.perimeter();
```
-- A: `20` and `62.83185307179586`
-- B: `20` and `NaN`
-- C: `20` and `63`
-- D: `NaN` and `63`
+- A: `20` y `62.83185307179586`
+- B: `20` y `NaN`
+- C: `20` y `63`
+- D: `NaN` y `63`
-Answer
+Solución
-#### Answer: B
+#### Respuesta Correcta: B
-Note that the value of `diameter` is a regular function, whereas the value of `perimeter` is an arrow function.
+Hay que tener en cuenta aqui que el valor de `diámetro` es una función regular o _normal_, mientras que el valor de `perímetro` es una función de flecha.
-With arrow functions, the `this` keyword refers to its current surrounding scope, unlike regular functions! This means that when we call `perimeter`, it doesn't refer to the shape object, but to its surrounding scope (window for example).
+Con las funciones de flecha, la palabra clave `this` se refiere a su ámbito actual, a diferencia de las funciones regulares. Esto significa que cuando llamamos "perímetro", no se refiere al objeto en sí mismo, sino a su ámbito circundante (ventana por ejemplo).
-There is no value `radius` on that object, which returns `undefined`.
+No hay valor `radius` en ese objeto, que devuelve` undefined`.
---
-###### 4. What's the output?
+###### 4. ¿Qué devuelve la siguiente función?
```javascript
+true;
!"Lydia";
```
-- A: `1` and `false`
-- B: `false` and `NaN`
-- C: `false` and `false`
+- A: `1` y `false`
+- B: `false` y `NaN`
+- C: `false` y `false`
-Answer
+Solución
-#### Answer: A
+#### Respuesta Correcta: A
-The unary plus tries to convert an operand to a number. `true` is `1`, and `false` is `0`.
+En el primera caso se intenta convertir un operando en un número. `true` es` 1`, y `false` es` 0`.
-The string `'Lydia'` is a truthy value. What we're actually asking, is "is this truthy value falsy?". This returns `false`.
+En el segundo caso la cadena `'Lydia'` es un valor verdadero. Lo que realmente estamos preguntando es "¿es este verdadero valor falso?". Esto devuelve `false`.
---
-###### 5. Which one is NOT valid?
+###### 5. ¿Cuál NO es válida?
```javascript
const bird = {
@@ -154,20 +153,20 @@ const mouse = {
- A: `mouse.bird.size`
- B: `mouse[bird.size]`
- C: `mouse[bird["size"]]`
-- D: All of them are valid
+- D: Todas son correctas
-Answer
+Solución
-#### Answer: A
+#### Respuesta Correcta: A
-In JavaScript, all object keys are strings (unless it's a Symbol). Even though we might not _type_ them as strings, they are always converted into strings under the hood.
+En JavaScript, todas las _keys_ son cadenas (a menos que sea un símbolo). A pesar de que no podríamos escribirlos como cadenas, siempre funcionan como cadenas de manera interna.
-JavaScript interprets (or unboxes) statements. When we use bracket notation, it sees the first opening bracket `[` and keeps going until it finds the closing bracket `]`. Only then, it will evaluate the statement.
+JavaScript interpreta declaraciones. Cuando usamos la notación de corchetes, ve el corchete de apertura `[` y continúa hasta que encuentra el corchete de cierre `]`. Solo de esta manera se evaluará la afirmación.
-`mouse[bird.size]`: First it evaluates `bird.size`, which is `"small"`. `mouse["small"]` returns `true`
+`mouse [bird.size]`: Primero evalúa `bird.size`, que es` "small" `. `mouse [" small "]` devuelve `true`
-However, with dot notation, this doesn't happen. `mouse` does not have a key called `bird`, which means that `mouse.bird` is `undefined`. Then, we ask for the `size` using dot notation: `mouse.bird.size`. Since `mouse.bird` is `undefined`, we're actually asking `undefined.size`. This isn't valid, and will throw an error similar to `Cannot read property "size" of undefined`.
+Sin embargo, con la notación de puntos, esto no sucede. `mouse` no tiene una clave llamada` bird`, lo que significa que `mouse.bird` es` undefined`. Luego, pedimos el `tamaño` usando la notación de puntos:` mouse.bird.size`. Como `mouse.bird` es` undefined`, en realidad estamos preguntando `undefined.size`. Esto no es válido y generará un error similar al `No se puede leer la propiedad" tamaño "de undefined`
@@ -176,7 +175,7 @@ However, with dot notation, this doesn't happen. `mouse` does not have a key cal
---
-###### 6. What's the output?
+###### 6. ¿Qué devuelve la siguiente función?
```javascript
let c = { greeting: "Hey!" };
@@ -192,25 +191,25 @@ console.log(d.greeting);
- C: `ReferenceError`
- D: `TypeError`
-Answer
+Solución
-#### Answer: A
+#### Respuesta Correcta: A
-In JavaScript, all objects interact by _reference_ when setting them equal to each other.
+En JavaScript, TODOS los objetos interactúan por referencia, de modo que cuando se establecen iguales o pasan a una función, todos apuntan a la misma ubicación, de modo que cuando cambia un objeto, los cambia a todos.
-First, variable `c` holds a value to an object. Later, we assign `d` with the same reference that `c` has to the object.
+Primero, la variable `c` tiene un valor para un objeto. Más tarde, asignamos `d` con la misma referencia que` c` tiene al objeto.
-
+
-When you change one object, you change all of them.
+Cuando cambias un objeto, cambias todos ellos.
---
-###### 7. What's the output?
+###### 7. ¿Qué devuelve la siguiente función?
```javascript
let a = 3;
@@ -227,23 +226,23 @@ console.log(b === c);
- C: `true` `false` `false`
- D: `false` `true` `true`
-Answer
+Solución
-#### Answer: C
+#### Respuesta Correcta: C
-`new Number()` is a built-in function constructor. Although it looks like a number, it's not really a number: it has a bunch of extra features and is an object.
+`new Number ()` es un constructor de funciones incorporado. Aunque parece un número, no es realmente un número: tiene muchas características adicionales y es un objeto.
-When we use the `==` operator, it only checks whether it has the same _value_. They both have the value of `3`, so it returns `true`.
+Cuando usamos el operador `==`, solo verifica si tiene el mismo _valor_. Ambos tienen el valor de `3`, por lo que devuelve` true`.
-However, when we use the `===` operator, both value _and_ type should be the same. It's not: `new Number()` is not a number, it's an **object**. Both return `false.`
+Sin embargo, cuando usamos el operador `===`, tanto el valor _ como el tipo deben ser iguales. No es: `new Number ()` no es un número, es un ** objeto **. Ambos devuelven "falso".
---
-###### 8. What's the output?
+###### 8. ¿Qué devuelve la siguiente función?
```javascript
class Chameleon {
@@ -266,19 +265,19 @@ freddie.colorChange("orange");
- C: `green`
- D: `TypeError`
-Answer
+Solución
-#### Answer: D
+#### Respuesta Correcta: D
-The `colorChange` function is static. Static methods are designed to live only on the constructor in which they are created, and cannot be passed down to any children. Since `freddie` is a child, the function is not passed down, and not available on the `freddie` instance: a `TypeError` is thrown.
+La función `colorChange` es estática. Los métodos estáticos están diseñados para _vivir_ solo en el constructor en el que se crean y no se pueden transmitir a ningún elemento secundario. Como `freddie` es un niño, la función no se transmite y no está disponible en la instancia de` freddie`: por lo tanto se lanza un `TypeError`.
---
-###### 9. What's the output?
+###### 9. ¿Qué devuelve la siguiente función?
```javascript
let greeting;
@@ -290,21 +289,21 @@ console.log(greetign);
- B: `ReferenceError: greetign is not defined`
- C: `undefined`
-Answer
+Solución
-#### Answer: A
+#### Respuesta Correcta: A
-It logs the object, because we just created an empty object on the global object! When we mistyped `greeting` as `greetign`, the JS interpreter actually saw this as `global.greetign = {}` (or `window.greetign = {}` in a browser).
+Lo que hace JS aquí es registrar el objeto debido a que acabamos de crear un objeto vacío en el objeto global. Cuando escribimos erróneamente `greeting` como` greetign`, el intérprete de JS ve esto como `global.greetign = {}` (o `window.greetign = {}` en un navegador).
-In order to avoid this, we can use `"use strict"`. This makes sure that you have declared a variable before setting it equal to anything.
+Para evitar esto, podemos usar el ["uso estricto"](https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Modo_estricto). Esto asegura que se haya declarado una variable antes de establecerla igual a cualquier cosa.
---
-###### 10. What happens when we do this?
+###### 10. ¿Qué ocurre cuando hacemos esto?
```javascript
function bark() {
@@ -314,19 +313,19 @@ function bark() {
bark.animal = "dog";
```
-- A: Nothing, this is totally fine!
-- B: `SyntaxError`. You cannot add properties to a function this way.
+- A: No pasa nada, es totalmente correcto.
+- B: `SyntaxError`. No es posible agregar propiedades a una función de esta manera.
- C: `undefined`
- D: `ReferenceError`
-Answer
+Solución
-#### Answer: A
+#### Respuesta Correcta: A
-This is possible in JavaScript, because functions are objects! (Everything besides primitive types are objects)
+Esto es perfectamente posible en JavaScript, porque las funciones son objetos (Recuerda: Todo aparte de los tipos primitivos son objetos en JS)
-A function is a special type of object. The code you write yourself isn't the actual function. The function is an object with properties. This property is invocable.
+Una función es un tipo especial de objeto. El código que escribes tú mismo no es la función real. La función es un objeto con propiedades. Esta propiedad es invocable.
From f0ecad3ab4702a75ccbbca937bf3ca1481cb1874 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Wed, 19 Jun 2019 13:35:23 +0200
Subject: [PATCH 006/881] Start translating in French
---
README-fr.md | 1295 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 1295 insertions(+)
create mode 100644 README-fr.md
diff --git a/README-fr.md b/README-fr.md
new file mode 100644
index 00000000..07406dfd
--- /dev/null
+++ b/README-fr.md
@@ -0,0 +1,1295 @@
+# Liste de questions JavaScript (Avancée)
+
+Je poste quotidiennement des questions à choix multiple sur mon [Instagram](https://www.instagram.com/theavocoder), que je posterai aussi ici !
+
+Des basiques au avancée: testez vos connaissances en JavaScript, rafraichissez vos connaissances, ou préparez vous pour un entretien de code ! :muscle: :rocket: Je mets à jour ce dépôt chaque semaine avec des nouvelles questions.
+
+Les réponses se trouvent dans les sections fermées en dessous des questions, cliquez simplement dessus pour les faire apparaitre. Bonne chance :heart:
+
+[English](./README.md)
+[中文版本](./README-zh_CN.md)
+[Русский](./README_ru-RU.md)
+[Western Balkan](./README-bs.md)
+
+---
+
+###### 1. Quelle est la sortie ?
+
+```javascript
+function sayHi() {
+ console.log(name);
+ console.log(age);
+ var name = "Lydia";
+ let age = 21;
+}
+
+sayHi();
+```
+
+- A: `Lydia` et `undefined`
+- B: `Lydia` et `ReferenceError`
+- C: `ReferenceError` et `21`
+- D: `undefined` et `ReferenceError`
+
+Réponse
+
+
+#### Réponse: D
+
+Within the function, we first declare the `name` variable with the `var` keyword. This means that the variable gets hoisted (memory space is set up during the creation phase) with the default value of `undefined`, until we actually get to the line where we define the variable. We haven't defined the variable yet on the line where we try to log the `name` variable, so it still holds the value of `undefined`.
+
+Variables with the `let` keyword (and `const`) are hoisted, but unlike `var`, don't get initialized. They are not accessible before the line we declare (initialize) them. This is called the "temporal dead zone". When we try to access the variables before they are declared, JavaScript throws a `ReferenceError`.
+
+
+
+
+---
+
+###### 2. Quelle est la sortie ?
+
+```javascript
+for (var i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+
+for (let i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+```
+
+- A: `0 1 2` et `0 1 2`
+- B: `0 1 2` et `3 3 3`
+- C: `3 3 3` et `0 1 2`
+
+Réponse
+
+
+#### Réponse: C
+
+Because of the event queue in JavaScript, the `setTimeout` callback function is called _after_ the loop has been executed. Since the variable `i` in the first loop was declared using the `var` keyword, this value was global. During the loop, we incremented the value of `i` by `1` each time, using the unary operator `++`. By the time the `setTimeout` callback function was invoked, `i` was equal to `3` in the first example.
+
+In the second loop, the variable `i` was declared using the `let` keyword: variables declared with the `let` (and `const`) keyword are block-scoped (a block is anything between `{ }`). During each iteration, `i` will have a new value, and each value is scoped inside the loop.
+
+
+
+
+---
+
+###### 3. Quelle est la sortie ?
+
+```javascript
+const shape = {
+ radius: 10,
+ diameter() {
+ return this.radius * 2;
+ },
+ perimeter: () => 2 * Math.PI * this.radius
+};
+
+shape.diameter();
+shape.perimeter();
+```
+
+- A: `20` et `62.83185307179586`
+- B: `20` et `NaN`
+- C: `20` et `63`
+- D: `NaN` et `63`
+
+Réponse
+
+
+#### Réponse: B
+
+Note that the value of `diameter` is a regular function, whereas the value of `perimeter` is an arrow function.
+
+With arrow functions, the `this` keyword refers to its current surrounding scope, unlike regular functions! This means that when we call `perimeter`, it doesn't refer to the shape object, but to its surrounding scope (window for example).
+
+There is no value `radius` on that object, which returns `undefined`.
+
+
+
+
+---
+
+###### 4. Quelle est la sortie ?
+
+```javascript
++true;
+!"Lydia";
+```
+
+- A: `1` et `false`
+- B: `false` et `NaN`
+- C: `false` et `false`
+
+Réponse
+
+
+#### Réponse: A
+
+The unary plus tries to convert an operand to a number. `true` is `1`, and `false` is `0`.
+
+The string `'Lydia'` is a truthy value. What we're actually asking, is "is this truthy value falsy?". This returns `false`.
+
+
+
+
+---
+
+###### 5. Which one is true?
+
+```javascript
+const bird = {
+ size: "small"
+};
+
+const mouse = {
+ name: "Mickey",
+ small: true
+};
+```
+
+- A: `mouse.bird.size` n'est pas valide
+- B: `mouse[bird.size]` n'est pas valide
+- C: `mouse[bird["size"]]` n'est pas valide
+- D: Toutes sont valides
+
+Réponse
+
+
+#### Réponse: A
+
+In JavaScript, all object keys are strings (unless it's a Symbol). Even though we might not _type_ them as strings, they are always converted into strings under the hood.
+
+JavaScript interprets (or unboxes) statements. When we use bracket notation, it sees the first opening bracket `[` and keeps going until it finds the closing bracket `]`. Only then, it will evaluate the statement.
+
+`mouse[bird.size]`: First it evaluates `bird.size`, which is `"small"`. `mouse["small"]` returns `true`
+
+However, with dot notation, this doesn't happen. `mouse` does not have a key called `bird`, which means that `mouse.bird` is `undefined`. Then, we ask for the `size` using dot notation: `mouse.bird.size`. Since `mouse.bird` is `undefined`, we're actually asking `undefined.size`. This isn't valid, and will throw an error similar to `Cannot read property "size" of undefined`.
+
+
+
+
+---
+
+---
+
+###### 6. Quelle est la sortie ?
+
+```javascript
+let c = { greeting: "Hey!" };
+let d;
+
+d = c;
+c.greeting = "Hello";
+console.log(d.greeting);
+```
+
+- A: `Hello`
+- B: `Hey`
+- C: `undefined`
+- D: `ReferenceError`
+- E: `TypeError`
+
+Réponse
+
+
+#### Réponse: A
+
+In JavaScript, all objects interact by _reference_ when setting them equal to each other.
+
+First, variable `c` holds a value to an object. Later, we assign `d` with the same reference that `c` has to the object.
+
+
+
+When you change one object, you change all of them.
+
+
+
+
+---
+
+###### 7. Quelle est la sortie ?
+
+```javascript
+let a = 3;
+let b = new Number(3);
+let c = 3;
+
+console.log(a == b);
+console.log(a === b);
+console.log(b === c);
+```
+
+- A: `true` `false` `true`
+- B: `false` `false` `true`
+- C: `true` `false` `false`
+- D: `false` `true` `true`
+
+Réponse
+
+
+#### Réponse: C
+
+`new Number()` is a built-in function constructor. Although it looks like a number, it's not really a number: it has a bunch of extra features and is an object.
+
+When we use the `==` operator, it only checks whether it has the same _value_. They both have the value of `3`, so it returns `true`.
+
+However, when we use the `===` operator, both value _and_ type should be the same. It's not: `new Number()` is not a number, it's an **object**. Both return `false.`
+
+
+
+
+---
+
+###### 8. Quelle est la sortie ?
+
+```javascript
+class Chameleon {
+ static colorChange(newColor) {
+ this.newColor = newColor;
+ return this.newColor;
+ }
+
+ constructor({ newColor = "green" } = {}) {
+ this.newColor = newColor;
+ }
+}
+
+const freddie = new Chameleon({ newColor: "purple" });
+freddie.colorChange("orange");
+```
+
+- A: `orange`
+- B: `purple`
+- C: `green`
+- D: `TypeError`
+
+Réponse
+
+
+#### Réponse: D
+
+The `colorChange` function is static. Static methods are designed to live only on the constructor in which they are created, and cannot be passed down to any children. Since `freddie` is a child, the function is not passed down, and not available on the `freddie` instance: a `TypeError` is thrown.
+
+
+
+
+---
+
+###### 9. Quelle est la sortie ?
+
+```javascript
+let greeting;
+greetign = {}; // Typo!
+console.log(greetign);
+```
+
+- A: `{}`
+- B: `ReferenceError: greetign is not defined`
+- C: `undefined`
+
+Réponse
+
+
+#### Réponse: A
+
+It logs the object, because we just created an empty object on the global object! When we mistyped `greeting` as `greetign`, the JS interpreter actually saw this as `global.greetign = {}` (or `window.greetign = {}` in a browser).
+
+In order to avoid this, we can use `"use strict"`. This makes sure that you have declared a variable before setting it equal to anything.
+
+
+
+
+---
+
+###### 10. Que ce passe-t-il lorsque nous faisons ça ?
+
+```javascript
+function bark() {
+ console.log("Woof!");
+}
+
+bark.animal = "dog";
+```
+
+- A: Rien, c'est tout à fait bon !
+- B: `SyntaxError`. Vous ne pouvez pas ajouter de propriétés à une fonction de cette façon.
+- C: `undefined`
+- D: `ReferenceError`
+
+Réponse
+
+
+#### Réponse: A
+
+This is possible in JavaScript, because functions are objects! (Everything besides primitive types are objects)
+
+A function is a special type of object. The code you write yourself isn't the actual function. The function is an object with properties. This property is invocable.
+
+
+
+
+---
+
+###### 11. Quelle est la sortie ?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const member = new Person("Lydia", "Hallie");
+Person.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+
+console.log(member.getFullName());
+```
+
+- A: `TypeError`
+- B: `SyntaxError`
+- C: `Lydia Hallie`
+- D: `undefined` `undefined`
+
+Réponse
+
+
+#### Réponse: A
+
+You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all objects at once, you have to use the prototype instead. So in this case,
+
+```js
+Person.prototype.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+```
+
+would have made `member.getFullName()` work. Why is this beneficial? Say that we added this method to the constructor itself. Maybe not every `Person` instance needed this method. This would waste a lot of memory space, since they would still have that property, which takes of memory space for each instance. Instead, if we only add it to the prototype, we just have it at one spot in memory, yet they all have access to it!
+
+
+
+
+---
+
+###### 12. Quelle est la sortie ?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const lydia = new Person("Lydia", "Hallie");
+const sarah = Person("Sarah", "Smith");
+
+console.log(lydia);
+console.log(sarah);
+```
+
+- A: `Person {firstName: "Lydia", lastName: "Hallie"}` et `undefined`
+- B: `Person {firstName: "Lydia", lastName: "Hallie"}` et `Person {firstName: "Sarah", lastName: "Smith"}`
+- C: `Person {firstName: "Lydia", lastName: "Hallie"}` et `{}`
+- D:`Person {firstName: "Lydia", lastName: "Hallie"}` et `ReferenceError`
+
+Réponse
+
+
+#### Réponse: A
+
+For `sarah`, we didn't use the `new` keyword. When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
+
+We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smith"`. What we actually did, is defining `global.firstName = 'Sarah'` and `global.lastName = 'Smith'`. `sarah` itself is left `undefined`.
+
+
+
+
+---
+
+###### 13. What are the three phases of event propagation?
+
+- A: Target > Capturing > Bubbling
+- B: Bubbling > Target > Capturing
+- C: Target > Bubbling > Capturing
+- D: Capturing > Target > Bubbling
+
+Réponse
+
+
+#### Réponse: D
+
+During the **capturing** phase, the event goes through the ancestor elements down to the target element. It then reaches the **target** element, and **bubbling** begins.
+
+
+
+
+
+
+---
+
+###### 14. Tous les objects ont des prototypes.
+
+- A: true
+- B: false
+
+Réponse
+
+
+#### Réponse: B
+
+All objects have prototypes, except for the **base object**. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
+
+
+
+
+---
+
+###### 15. Quelle est la sortie ?
+
+```javascript
+function sum(a, b) {
+ return a + b;
+}
+
+sum(1, "2");
+```
+
+- A: `NaN`
+- B: `TypeError`
+- C: `"12"`
+- D: `3`
+
+Réponse
+
+
+#### Réponse: C
+
+JavaScript is a **dynamically typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
+
+In this example, JavaScript converts the number `1` into a string, in order for the function to make sense and return a value. During the addition of a numeric type (`1`) and a string type (`'2'`), the number is treated as a string. We can concatenate strings like `"Hello" + "World"`, so what's happening here is `"1" + "2"` which returns `"12"`.
+
+
+
+
+---
+
+###### 16. Quelle est la sortie ?
+
+```javascript
+let number = 0;
+console.log(number++);
+console.log(++number);
+console.log(number);
+```
+
+- A: `1` `1` `2`
+- B: `1` `2` `2`
+- C: `0` `2` `2`
+- D: `0` `1` `2`
+
+Réponse
+
+
+#### Réponse: C
+
+The **postfix** unary operator `++`:
+
+1. Returns the value (this returns `0`)
+2. Increments the value (number is now `1`)
+
+The **prefix** unary operator `++`:
+
+1. Increments the value (number is now `2`)
+2. Returns the value (this returns `2`)
+
+This returns `0 2 2`.
+
+
+
+
+---
+
+###### 17. Quelle est la sortie ?
+
+```javascript
+function getPersonInfo(one, two, three) {
+ console.log(one);
+ console.log(two);
+ console.log(three);
+}
+
+const person = "Lydia";
+const age = 21;
+
+getPersonInfo`${person} is ${age} years old`;
+```
+
+- A: `"Lydia"` `21` `["", " is ", " years old"]`
+- B: `["", " is ", " years old"]` `"Lydia"` `21`
+- C: `"Lydia"` `["", " is ", " years old"]` `21`
+
+Réponse
+
+
+#### Réponse: B
+
+If you use tagged template literals, the value of the first argument is always an array of the string values. The remaining arguments get the values of the passed expressions!
+
+
+
+
+---
+
+###### 18. Quelle est la sortie ?
+
+```javascript
+function checkAge(data) {
+ if (data === { age: 18 }) {
+ console.log("Vous êtes un adulte !");
+ } else if (data == { age: 18 }) {
+ console.log("Vous êtes toujours un adulte.");
+ } else {
+ console.log(`Hmm.. Vous n'avez pas l'âge, je suppose.`);
+ }
+}
+
+checkAge({ age: 18 });
+```
+
+- A: `Vous êtes un adulte !`
+- B: `Vous êtes toujours un adulte.`
+- C: `Hmm.. Vous n'avez pas l'âge, je suppose.`
+
+Réponse
+
+
+#### Réponse: C
+
+When testing equality, primitives are compared by their _value_, while objects are compared by their _reference_. JavaScript checks if the objects have a reference to the same location in memory.
+
+The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
+
+This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }` return `false`.
+
+
+
+
+---
+
+###### 19. Quelle est la sortie ?
+
+```javascript
+function getAge(...args) {
+ console.log(typeof args);
+}
+
+getAge(21);
+```
+
+- A: `"number"`
+- B: `"array"`
+- C: `"object"`
+- D: `"NaN"`
+
+Réponse
+
+
+#### Réponse: C
+
+The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
+
+
+
+
+---
+
+###### 20. Quelle est la sortie ?
+
+```javascript
+function getAge() {
+ "use strict";
+ age = 21;
+ console.log(age);
+}
+
+getAge();
+```
+
+- A: `21`
+- B: `undefined`
+- C: `ReferenceError`
+- D: `TypeError`
+
+Réponse
+
+
+#### Réponse: C
+
+With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. If we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
+
+
+
+
+---
+
+###### 21. Quelle est la valeur de `sum` ?
+
+```javascript
+const sum = eval("10*10+5");
+```
+
+- A: `105`
+- B: `"105"`
+- C: `TypeError`
+- D: `"10*10+5"`
+
+Réponse
+
+
+#### Réponse: A
+
+`eval` evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is `10 * 10 + 5`. This returns the number `105`.
+
+
+
+
+---
+
+###### 22. Pendant combien de temps `cool_secret` sera-t'il accessible ?
+
+```javascript
+sessionStorage.setItem("cool_secret", 123);
+```
+
+- A: Pour toujours, les données ne seront pas perdues.
+- B: Jusqu'à ce que l'utilisateur ferme l'onglet.
+- C: Jusqu'à ce que l'utilisateur ferme son navigateur en entier, pas seulement son onglet.
+- D: Jusqu'à ce que l'utilisateur éteindra son ordinateur.
+
+Réponse
+
+
+#### Réponse: B
+
+The data stored in `sessionStorage` is removed after closing the _tab_.
+
+If you used `localStorage`, the data would've been there forever, unless for example `localStorage.clear()` is invoked.
+
+
+
+
+---
+
+###### 23. Quelle est la sortie ?
+
+```javascript
+var num = 8;
+var num = 10;
+
+console.log(num);
+```
+
+- A: `8`
+- B: `10`
+- C: `SyntaxError`
+- D: `ReferenceError`
+
+Réponse
+
+
+#### Réponse: B
+
+With the `var` keyword, you can declare multiple variables with the same name. The variable will then hold the latest value.
+
+You cannot do this with `let` or `const` since they're block-scoped.
+
+
+
+
+---
+
+###### 24. Quelle est la sortie ?
+
+```javascript
+const obj = { 1: "a", 2: "b", 3: "c" };
+const set = new Set([1, 2, 3, 4, 5]);
+
+obj.hasOwnProperty("1");
+obj.hasOwnProperty(1);
+set.has("1");
+set.has(1);
+```
+
+- A: `false` `true` `false` `true`
+- B: `false` `true` `true` `true`
+- C: `true` `true` `false` `true`
+- D: `true` `true` `true` `true`
+
+Réponse
+
+
+#### Réponse: C
+
+All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
+
+It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')` returns `false`. It has the numeric type `1`, `set.has(1)` returns `true`.
+
+
+
+
+---
+
+###### 25. Quelle est la sortie ?
+
+```javascript
+const obj = { a: "un", b: "deux", a: "trois" };
+console.log(obj);
+```
+
+- A: `{ a: "un", b: "deux" }`
+- B: `{ b: "deux", a: "trois" }`
+- C: `{ a: "trois", b: "deux" }`
+- D: `SyntaxError`
+
+Réponse
+
+
+#### Réponse: C
+
+If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
+
+
+
+
+---
+
+###### 26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
+
+- A: Vrai
+- B: Faux
+- C: Ça dépends
+
+Réponse
+
+
+#### Réponse: A
+
+The base execution context is the global execution context: it's what's accessible everywhere in your code.
+
+
+
+
+---
+
+###### 27. Quelle est la sortie ?
+
+```javascript
+for (let i = 1; i < 5; i++) {
+ if (i === 3) continue;
+ console.log(i);
+}
+```
+
+- A: `1` `2`
+- B: `1` `2` `3`
+- C: `1` `2` `4`
+- D: `1` `3` `4`
+
+Réponse
+
+
+#### Réponse: C
+
+The `continue` statement skips an iteration if a certain condition returns `true`.
+
+
+
+
+---
+
+###### 28. Quelle est la sortie ?
+
+```javascript
+String.prototype.giveLydiaPizza = () => {
+ return "Just give Lydia pizza already!";
+};
+
+const name = "Lydia";
+
+name.giveLydiaPizza();
+```
+
+- A: `"Just give Lydia pizza already!"`
+- B: `TypeError: not a function`
+- C: `SyntaxError`
+- D: `undefined`
+
+Réponse
+
+
+#### Réponse: A
+
+`String` is a built-in constructor, which we can add properties to. I just added a method to its prototype. Primitive strings are automatically converted into a string object, generated by the string prototype function. So, all strings (string objects) have access to that method!
+
+
+
+
+---
+
+###### 29. Quelle est la sortie ?
+
+```javascript
+const a = {};
+const b = { key: "b" };
+const c = { key: "c" };
+
+a[b] = 123;
+a[c] = 456;
+
+console.log(a[b]);
+```
+
+- A: `123`
+- B: `456`
+- C: `undefined`
+- D: `ReferenceError`
+
+Réponse
+
+
+#### Réponse: B
+
+Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`.
+
+However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
+
+Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to `456`, so it returns `456`.
+
+
+
+
+---
+
+###### 30. Quelle est la sortie ?
+
+```javascript
+const foo = () => console.log("Premier");
+const bar = () => setTimeout(() => console.log("Second"));
+const baz = () => console.log("Troisième");
+
+bar();
+foo();
+baz();
+```
+
+- A: `Premier` `Second` `Troisième`
+- B: `Premier` `Troisième` `Second`
+- C: `Second` `Premier` `Troisième`
+- D: `Second` `Troisième` `Premier`
+
+Réponse
+
+
+#### Réponse: B
+
+We have a `setTimeout` function and invoked it first. Yet, it was logged last.
+
+This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
+
+After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
+
+
+
+Now, `foo` gets invoked, and `"First"` is being logged.
+
+
+
+`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged.
+
+
+
+The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_.
+
+
+
+This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
+
+
+
+`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack.
+
+
+
+
+---
+
+###### 31. What is the event.target when clicking the button?
+
+```html
+
+```
+
+- A: Outer `div`
+- B: Inner `div`
+- C: `button`
+- D: An array of all nested elements.
+
+Réponse
+
+
+#### Réponse: C
+
+The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+
+
+
+
+---
+
+###### 32. When you click the paragraph, what's the logged output?
+
+```html
+
+```
+
+- A: `p` `div`
+- B: `div` `p`
+- C: `p`
+- D: `div`
+
+Réponse
+
+
+#### Réponse: A
+
+If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
+
+
+
+
+---
+
+###### 33. Quelle est la sortie ?
+
+```javascript
+const person = { name: "Lydia" };
+
+function sayHi(age) {
+ console.log(`${this.name} is ${age}`);
+}
+
+sayHi.call(person, 21);
+sayHi.bind(person, 21);
+```
+
+- A: `undefined is 21` `Lydia is 21`
+- B: `function` `function`
+- C: `Lydia is 21` `Lydia is 21`
+- D: `Lydia is 21` `function`
+
+Réponse
+
+
+#### Réponse: D
+
+With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
+
+`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
+
+
+
+
+---
+
+###### 34. Quelle est la sortie ?
+
+```javascript
+function sayHi() {
+ return (() => 0)();
+}
+
+typeof sayHi();
+```
+
+- A: `"object"`
+- B: `"number"`
+- C: `"function"`
+- D: `"undefined"`
+
+Réponse
+
+
+#### Réponse: B
+
+The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+
+FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+
+
+
+
+---
+
+###### 35. Which of these values are falsy?
+
+```javascript
+0;
+new Number(0);
+("");
+(" ");
+new Boolean(false);
+undefined;
+```
+
+- A: `0`, `''`, `undefined`
+- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
+- C: `0`, `''`, `new Boolean(false)`, `undefined`
+- D: All of them are falsy
+
+Réponse
+
+
+#### Réponse: A
+
+There are only six falsy values:
+
+- `undefined`
+- `null`
+- `NaN`
+- `0`
+- `''` (empty string)
+- `false`
+
+Function constructors, like `new Number` and `new Boolean` are truthy.
+
+
+
+
+---
+
+###### 36. Quelle est la sortie ?
+
+```javascript
+console.log(typeof typeof 1);
+```
+
+- A: `"number"`
+- B: `"string"`
+- C: `"object"`
+- D: `"undefined"`
+
+Réponse
+
+
+#### Réponse: B
+
+`typeof 1` returns `"number"`.
+`typeof "number"` returns `"string"`
+
+
+
+
+---
+
+###### 37. Quelle est la sortie ?
+
+```javascript
+const numbers = [1, 2, 3];
+numbers[10] = 11;
+console.log(numbers);
+```
+
+- A: `[1, 2, 3, 7 x null, 11]`
+- B: `[1, 2, 3, 11]`
+- C: `[1, 2, 3, 7 x empty, 11]`
+- D: `SyntaxError`
+
+Réponse
+
+
+#### Réponse: C
+
+When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like:
+
+`[1, 2, 3, 7 x empty, 11]`
+
+depending on where you run it (it's different for every browser, node, etc.)
+
+
+
+
+---
+
+###### 38. Quelle est la sortie ?
+
+```javascript
+(() => {
+ let x, y;
+ try {
+ throw new Error();
+ } catch (x) {
+ (x = 1), (y = 2);
+ console.log(x);
+ }
+ console.log(x);
+ console.log(y);
+})();
+```
+
+- A: `1` `undefined` `2`
+- B: `undefined` `undefined` `undefined`
+- C: `1` `1` `2`
+- D: `1` `undefined` `undefined`
+
+Réponse
+
+
+#### Réponse: A
+
+The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
+
+Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+
+Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+
+
+
+
+---
+
+###### 39. Everything in JavaScript is either a...
+
+- A: primitive or object
+- B: function or object
+- C: trick question! only objects
+- D: number or object
+
+Réponse
+
+
+#### Réponse: A
+
+JavaScript only has primitive types and objects.
+
+Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+
+What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+
+
+
+
+---
+
+###### 40. Quelle est la sortie ?
+
+```javascript
+[[0, 1], [2, 3]].reduce(
+ (acc, cur) => {
+ return acc.concat(cur);
+ },
+ [1, 2]
+);
+```
+
+- A: `[0, 1, 2, 3, 1, 2]`
+- B: `[6, 1, 2]`
+- C: `[1, 2, 0, 1, 2, 3]`
+- D: `[1, 2, 6]`
+
+Réponse
+
+
+#### Réponse: C
+
+`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
+
+Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
+
+
+
+
+---
+
+###### 41. Quelle est la sortie ?
+
+```javascript
+!!null;
+!!"";
+!!1;
+```
+
+- A: `false` `true` `false`
+- B: `false` `false` `true`
+- C: `false` `true` `true`
+- D: `true` `true` `false`
+
+Réponse
+
+
+#### Réponse: B
+
+`null` is falsy. `!null` returns `true`. `!true` returns `false`.
+
+`""` is falsy. `!""` returns `true`. `!true` returns `false`.
+
+`1` is truthy. `!1` returns `false`. `!false` returns `true`.
+
+
+
+
+---
+
+###### 42. What does the `setInterval` method return?
+
+```javascript
+setInterval(() => console.log("Hi"), 1000);
+```
+
+- A: a unique id
+- B: the amount of milliseconds specified
+- C: the passed function
+- D: `undefined`
+
+Réponse
+
+
+#### Réponse: A
+
+It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function.
+
+
+
+
+---
+
+###### 43. What does this return?
+
+```javascript
+[..."Lydia"];
+```
+
+- A: `["L", "y", "d", "i", "a"]`
+- B: `["Lydia"]`
+- C: `[[], "Lydia"]`
+- D: `[["L", "y", "d", "i", "a"]]`
+
+Réponse
+
+
+#### Réponse: A
+
+A string is an iterable. The spread operator maps every character of an iterable to one element.
+
+
+
From e76de07a67f976217d29bde8dc42f6e272d06fdd Mon Sep 17 00:00:00 2001
From: madbbb
Date: Wed, 19 Jun 2019 15:52:56 +0300
Subject: [PATCH 007/881] Update README.md
c.greeting is "Hey!"
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index f6fb9dc4..6aee9c96 100644
--- a/README.md
+++ b/README.md
@@ -185,7 +185,7 @@ console.log(d.greeting);
```
- A: `Hello`
-- B: `Hey`
+- B: `Hey!`
- C: `undefined`
- D: `ReferenceError`
- E: `TypeError`
From 54b14fb7dff02bce978790eca83e9b640364ed45 Mon Sep 17 00:00:00 2001
From: nedimf <24845593+nedimf@users.noreply.github.com>
Date: Wed, 19 Jun 2019 18:34:46 +0200
Subject: [PATCH 008/881] Western Balkan link was outdated
Fixed Western Balkan link
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index f1d14d90..916fa133 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ The answers are in the collapsed sections below the questions, simply click on t
[中文版本](./README-zh_CN.md)
[Русский](./README_ru-RU.md)
-[Western Balkan](./README-bs.md)
+[Western Balkan](./README-bs_BS.md)
[Deutsch](./README-de_DE.md)
[Tiếng Việt](./README-vi.md)
From c3856a6407646bf5f8ad303437868605bd9a6971 Mon Sep 17 00:00:00 2001
From: heyitskippy
Date: Wed, 19 Jun 2019 19:41:21 +0300
Subject: [PATCH 009/881] README-ru_RU.md: fix question 10 - answer A
+ update the translation list
---
README_ru-RU.md | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index a4eb0829..4cd821f5 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -7,7 +7,10 @@
Ответы находятся в свернутой секции ниже вопросов. Просто нажми на ответ, чтобы развернуть. Удачи! :heart:
[中文版本](./README-zh_CN.md)
-[Русский](./README_ru-RU.md)
+[Русский](./README_ru-RU.md)
+[Western Balkan](./README-bs.md)
+[Deutsch](./README-de_DE.md)
+[Tiếng Việt](./README-vi.md)
---
@@ -322,8 +325,7 @@ bark.animal = "dog";
В JavaScript это возможно, т.к. функции это объекты! (Всё есть объект кроме примитивов).
-Функция это специальный тип объекта, который можно вызвать. Функция это объект со свойствами.
-A function is a special type of object. The code you write yourself isn't the actual function. The function is an object with properties. This property is invocable.
+Функция — это специальный тип объекта, который можно вызвать. Кроме того, функция — это объект со свойствами. Свойство такого объекта нельзя вызвать, так как оно не является функцией.
From fffc6d180b9867792ed8fa3995b82e6abf51cdef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n?= <22575055+aguadotzn@users.noreply.github.com>
Date: Wed, 19 Jun 2019 23:12:20 +0200
Subject: [PATCH 010/881] Questions 10-20
---
README-ES.md | 126 +++++++++++++++++++++++++--------------------------
1 file changed, 62 insertions(+), 64 deletions(-)
diff --git a/README-ES.md b/README-ES.md
index a1f667c6..e9cb0a1b 100644
--- a/README-ES.md
+++ b/README-ES.md
@@ -36,7 +36,7 @@ sayHi();
Solución
-#### Respuesta Correcta: D
+#### Respuesta correcta: D
Dentro de la función, primero declaramos la variable `name` con la palabra reservada ` var`. Esto significa que la variable se _eleva_ (el espacio de memoria se configura durante la fase de creación. Hace referencia al termino [hoisting](https://developer.mozilla.org/es/docs/Glossary/Hoisting)) con el valor predeterminado de `indefinido`, hasta que realmente llegamos a la línea donde definimos la variable. Aún no hemos definido la variable en la línea donde intentamos registrar la variable `name`, por lo que aún mantiene el valor de` undefined`.
@@ -65,7 +65,7 @@ for (let i = 0; i < 3; i++) {
Solución
-#### Respuesta Correcta: C
+#### Respuesta correcta: C
Debido a la cola de eventos en JavaScript, la función `setTimeout` se llama una vez el ciclo se ha ejecutado. Dado que la variable `i` en el primer bucle se declaró utilizando la palabra reservada ` var`, este valor es global. Durante el bucle, incrementamos el valor de `i` en` 1` cada vez, utilizando el operador unario `++`. Cuando se invocó la función `setTimeout`,` i` era igual a `3` en el primer ejemplo.
@@ -99,7 +99,7 @@ shape.perimeter();
Solución
-#### Respuesta Correcta: B
+#### Respuesta correcta: B
Hay que tener en cuenta aqui que el valor de `diámetro` es una función regular o _normal_, mientras que el valor de `perímetro` es una función de flecha.
@@ -126,7 +126,7 @@ No hay valor `radius` en ese objeto, que devuelve` undefined`.
Solución
-#### Respuesta Correcta: A
+#### Respuesta correcta: A
En el primera caso se intenta convertir un operando en un número. `true` es` 1`, y `false` es` 0`.
@@ -158,7 +158,7 @@ const mouse = {
Solución
-#### Respuesta Correcta: A
+#### Respuesta correcta: A
En JavaScript, todas las _keys_ son cadenas (a menos que sea un símbolo). A pesar de que no podríamos escribirlos como cadenas, siempre funcionan como cadenas de manera interna.
@@ -173,8 +173,6 @@ Sin embargo, con la notación de puntos, esto no sucede. `mouse` no tiene una cl
---
----
-
###### 6. ¿Qué devuelve la siguiente función?
```javascript
@@ -194,7 +192,7 @@ console.log(d.greeting);
Solución
-#### Respuesta Correcta: A
+#### Respuesta correcta: A
En JavaScript, TODOS los objetos interactúan por referencia, de modo que cuando se establecen iguales o pasan a una función, todos apuntan a la misma ubicación, de modo que cuando cambia un objeto, los cambia a todos.
@@ -229,7 +227,7 @@ console.log(b === c);
Solución
-#### Respuesta Correcta: C
+#### Respuesta correcta: C
`new Number ()` es un constructor de funciones incorporado. Aunque parece un número, no es realmente un número: tiene muchas características adicionales y es un objeto.
@@ -268,7 +266,7 @@ freddie.colorChange("orange");
Solución
-#### Respuesta Correcta: D
+#### Respuesta correcta: D
La función `colorChange` es estática. Los métodos estáticos están diseñados para _vivir_ solo en el constructor en el que se crean y no se pueden transmitir a ningún elemento secundario. Como `freddie` es un niño, la función no se transmite y no está disponible en la instancia de` freddie`: por lo tanto se lanza un `TypeError`.
@@ -292,7 +290,7 @@ console.log(greetign);
Solución
-#### Respuesta Correcta: A
+#### Respuesta correcta: A
Lo que hace JS aquí es registrar el objeto debido a que acabamos de crear un objeto vacío en el objeto global. Cuando escribimos erróneamente `greeting` como` greetign`, el intérprete de JS ve esto como `global.greetign = {}` (o `window.greetign = {}` en un navegador).
@@ -321,7 +319,7 @@ bark.animal = "dog";
Solución
-#### Respuesta Correcta: A
+#### Respuesta correcta: A
Esto es perfectamente posible en JavaScript, porque las funciones son objetos (Recuerda: Todo aparte de los tipos primitivos son objetos en JS)
@@ -332,7 +330,7 @@ Una función es un tipo especial de objeto. El código que escribes tú mismo no
---
-###### 11. What's the output?
+###### 11. ¿Qué devuelve la siguiente función?
```javascript
function Person(firstName, lastName) {
@@ -353,27 +351,27 @@ console.log(member.getFullName());
- C: `Lydia Hallie`
- D: `undefined` `undefined`
-Answer
+Solución
-#### Answer: A
+#### Respuesta correcta: A
-You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all objects at once, you have to use the prototype instead. So in this case,
+En JS no se pueden añadir propiedades a un constructor como se puede hacer con los objetos. Si se desea añadir una característica a todos los objetos a la vez, se debe utilizar el [prototipo](https://www.w3schools.com/js/js_object_prototypes.asp) en su lugar. Así que en este caso,
```js
-Person.prototype.getFullName = function () {
- return `${this.firstName} ${this.lastName}`;
+Persona.prototipo.getFullName = función () {)
+ devuelve `${este.nombre} ${este.apellido}`;
}
```
-would have made `member.getFullName()` work. Why is this beneficial? Say that we added this method to the constructor itself. Maybe not every `Person` instance needed this method. This would waste a lot of memory space, since they would still have that property, which takes of memory space for each instance. Instead, if we only add it to the prototype, we just have it at one spot in memory, yet they all have access to it!
+habría hecho que `member.getFullName()` funcionara. ¿Por qué es bueno? Imaginemos que añadimos este método al constructor. Quizás no todas las "personas" necesitaban este método. Esto desperdiciaría mucho espacio de memoria, ya que todavía tendrían esa propiedad, que ocupa espacio de memoria para cada caso. En cambio, si sólo lo añadimos al prototipo, sólo lo tenemos en un lugar en la memoria, ¡pero todos ellos tienen acceso a él!
---
-###### 12. What's the output?
+###### 12. ¿Qué devuelve la siguiente función?
```javascript
function Person(firstName, lastName) {
@@ -393,33 +391,33 @@ console.log(sarah);
- C: `Person {firstName: "Lydia", lastName: "Hallie"}` and `{}`
- D:`Person {firstName: "Lydia", lastName: "Hallie"}` and `ReferenceError`
-Answer
+Solución
-#### Answer: A
+#### Respuesta correcta: A
-For `sarah`, we didn't use the `new` keyword. When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
+Para `sarah`, no usamos la palabra reservada `new`. Cuando se usa `new`, se refiere al nuevo objeto vacío que creamos. Sin embargo, si no se agrega `new', se refiere al **objeto global**!
-We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smith"`. What we actually did, is defining `global.firstName = 'Sarah'` and `global.lastName = 'Smith'`. `sarah` itself is left `undefined`.
+En el ejemplo `this.firstName` equivale a `"Sarah"` y `this.lastName` equivale a `"Smith"`. Lo que realmente hicimos fue definir `global.firstName = `Sarah'` y `global.lastName = `Smith'`. La misma `sarah` se deja `indefinida`.
---
-###### 13. What are the three phases of event propagation?
+###### 13. ¿Cuáles son las tres fases de la propagación de eventos?
- A: Target > Capturing > Bubbling
- B: Bubbling > Target > Capturing
- C: Target > Bubbling > Capturing
- D: Capturing > Target > Bubbling
-Answer
+Solución
-#### Answer: D
+#### Respuesta correcta: D
-During the **capturing** phase, the event goes through the ancestor elements down to the target element. It then reaches the **target** element, and **bubbling** begins.
+Durante la fase de **Capturing**, el evento pasa a través de los elementos ancestrales hasta el elemento objetivo. A continuación, alcanza el elemento **Target** y comienza el **bubbling**. Más información [aquí](https://www.sitepoint.com/event-bubbling-javascript/).
@@ -433,19 +431,19 @@ During the **capturing** phase, the event goes through the ancestor elements dow
- A: true
- B: false
-Answer
+Solución
-#### Answer: B
+#### Respuesta correcta: B
-All objects have prototypes, except for the **base object**. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
+Todos los objetos tienen prototipos, excepto el **objeto base** (Más info [aquí](https://stackoverflow.com/questions/56659303/what-is-base-object-in-javascript)). El componente tiene acceso a algunos métodos y propiedades, como `.toString`. Esta es la razón principal por la que se puede utilizar los métodos JavaScript incorporados. Todos estos métodos están disponibles en el prototipo. Aunque JavaScript no puede encontrar de manera directa en su objeto, baja por la cadena de prototipos y lo encuentra allí, lo que lo hace accesible para poder usarse posteriormente.
---
-###### 15. What's the output?
+###### 15. ¿Qué devuelve la siguiente función?
```javascript
function sum(a, b) {
@@ -460,21 +458,21 @@ sum(1, "2");
- C: `"12"`
- D: `3`
-Answer
+Solución
-#### Answer: C
+#### Respuesta correcta: C
-JavaScript is a **dynamically typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
+JavaScript es un **lenguaje dinámicamente tipado** o de tipado débil, esto significa que no es necesario declarar el tipo de variable antes de usarla pues será determinado automáticamente cuando el programa comience a ser procesado. Los valores se pueden convertir automáticamente en otro tipo sin que se sepa, esto se llama denomina _implicit type coercion_ (Más info [aquí](https://medium.com/@ManuCastrillonM/entendiendo-la-coerci%C3%B3n-en-javascript-bc202d22d23f)). **La coerción es la conversión de un tipo a otro.**
-In this example, JavaScript converts the number `1` into a string, in order for the function to make sense and return a value. During the addition of a numeric type (`1`) and a string type (`'2'`), the number is treated as a string. We can concatenate strings like `"Hello" + "World"`, so what's happening here is `"1" + "2"` which returns `"12"`.
+En este ejemplo, JavaScript convierte el número `1` en una cadena, para que la función tenga sentido y devuelva un valor. Durante la suma de un tipo numérico (`1`) y un tipo de cadena (`'2'`), el número se trata como una cadena. Podemos concatenar cadenas como `"Hello" + "World"``, así que lo que está pasando aquí es `"1" + "2"` que devuelve `"12"`
---
-###### 16. What's the output?
+###### 16. ¿Qué devuelve la siguiente función?
```javascript
let number = 0;
@@ -488,29 +486,29 @@ console.log(number);
- C: `0` `2` `2`
- D: `0` `1` `2`
-Answer
+Solución
-#### Answer: C
+#### Respuesta correcta: C
-The **postfix** unary operator `++`:
+El operador **postfix** unario `++`:
-1. Returns the value (this returns `0`)
-2. Increments the value (number is now `1`)
+1. Devuelve el valor (esto devuelve `0`)
+2. Incrementa el valor (el número es ahora `1`)
-The **prefix** unary operator `++`:
+El operador unario **prefix** `++`:
-1. Increments the value (number is now `2`)
-2. Returns the value (this returns `2`)
+1. Incrementa el valor (el número es ahora `2`)
+2. Devuelve el valor (esto devuelve `2`)
-This returns `0 2 2`.
+Por lo tanto, devuelve `0 2 2 2`.
---
-###### 17. What's the output?
+###### 17. ¿Qué devuelve la siguiente función?
```javascript
function getPersonInfo(one, two, three) {
@@ -529,19 +527,19 @@ getPersonInfo`${person} is ${age} years old`;
- B: `["", " is ", " years old"]` `"Lydia"` `21`
- C: `"Lydia"` `["", " is ", " years old"]` `21`
-Answer
+Solución
-#### Answer: B
+#### Respuesta correcta: B
-If you use tagged template literals, the value of the first argument is always an array of the string values. The remaining arguments get the values of the passed expressions!
+_Tagged templates_ es un caso de uso de [template literals](https://codeburst.io/javascript-template-literals-tag-functions-for-beginners-758a041160e1). Una _plantilla etiquetada_ es una llamada de función que utiliza una plantilla literal de la que obtener sus argumentos. Si se usan literales de plantillas etiquetadas, el valor del primer argumento es siempre una matriz de los valores de las cadenas. El resto de los argumentos obtienen los valores de las expresiones pasadas.
---
-###### 18. What's the output?
+###### 18. ¿Qué devuelve la siguiente función?
```javascript
function checkAge(data) {
@@ -561,23 +559,23 @@ checkAge({ age: 18 });
- B: `You are still an adult.`
- C: `Hmm.. You don't have an age I guess`
-Answer
+Solución
-#### Answer: C
+#### Respuesta correcta: C
-When testing equality, primitives are compared by their _value_, while objects are compared by their _reference_. JavaScript checks if the objects have a reference to the same location in memory.
+Al probar la igualdad, las primitivas se comparan por su _valor_, mientras que los objetos se comparan por su _referencia_. JavaScript comprueba si los objetos tienen una referencia a la misma ubicación en la memoria.
-The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
+Los dos objetos que estamos comparando no tienen eso: el objeto que pasamos como parámetro se refiere a una ubicación diferente en la memoria que el objeto que usamos para comprobar la igualdad.
-This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }` return `false`.
+Esta es la razón por la que ambos `{ edad: 18 } === { edad: 18 }` y `{ edad: 18 }} == { edad: 18 }` devuelven `false`
---
-###### 19. What's the output?
+###### 19. ¿Qué devuelve la siguiente función?
```javascript
function getAge(...args) {
@@ -592,19 +590,19 @@ getAge(21);
- C: `"object"`
- D: `"NaN"`
-Answer
+Solución
-#### Answer: C
+#### Respuesta correcta: C
-The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
+El operador spread (`...args`.) devuelve un array con argumentos. Una matriz es un objeto, así que `typeof args` devuelve `"object"`
---
-###### 20. What's the output?
+###### 20. ¿Qué devuelve la siguiente función?
```javascript
function getAge() {
@@ -621,12 +619,12 @@ getAge();
- C: `ReferenceError`
- D: `TypeError`
-Answer
+Solución
-#### Answer: C
+#### Respuesta correcta: C
-With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. If we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
+Con `"use strict"`, es posible asegurarse de que no se declara accidentalmente variables globales. Nunca declaramos la variable `age`, y como usamos `"use strict"`, nos dará un error de referencia. Si no hubiéramos usado `"use strict"`, habría funcionado, ya que la propiedad `age` se habría añadido al objeto global.
From 5068bc52fba5e0dbb9820d9526331885a2f65234 Mon Sep 17 00:00:00 2001
From: Ihor Sychevskyi <26163841+Arhell@users.noreply.github.com>
Date: Thu, 20 Jun 2019 01:07:55 +0300
Subject: [PATCH 011/881] Fix typo, Ru
---
README_ru-RU.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index a4eb0829..afdbb8b2 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -2,7 +2,7 @@
Я ежедевно публикую вопросы по JavaScript с вариантами ответов в своем [Instagram](https://www.instagram.com/theavocoder), которые дублируются в этом репозитории.
-От азов к сложным вопросам: провеь как хорошо ты знаешь JavaScript, освежи свои знания или приготовься к собеседованию! :muscle: :rocket: Я дополняю этот репозиторий каждую неделю новыми вопросами.
+От азов к сложным вопросам: проверь как хорошо ты знаешь JavaScript, освежи свои знания или приготовься к собеседованию! :muscle: :rocket: Я дополняю этот репозиторий каждую неделю новыми вопросами.
Ответы находятся в свернутой секции ниже вопросов. Просто нажми на ответ, чтобы развернуть. Удачи! :heart:
From 294ab31520e531f64f20371ffb6f82e3e7839744 Mon Sep 17 00:00:00 2001
From: Guilherme Nogara
Date: Wed, 19 Jun 2019 20:03:41 -0300
Subject: [PATCH 012/881] started pt_BR README
---
README_pt_BR.md | 1298 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 1298 insertions(+)
create mode 100644 README_pt_BR.md
diff --git a/README_pt_BR.md b/README_pt_BR.md
new file mode 100644
index 00000000..6c3cfd85
--- /dev/null
+++ b/README_pt_BR.md
@@ -0,0 +1,1298 @@
+# Lista de questões (avançadas) sobre JavaScript
+
+Posto questões de múltipla escolha sobre JavaScript no meu [Instagram](https://www.instagram.com/theavocoder), as quais também posto aqui!
+
+Do básico ao avançado: Teste quão bem você conhece o JavaScript, refresce um pouco do seu conhecimento, ou se prepare para uma entrevista! :muscle: :rocket: Eu atualizo esse repositório semanalmente com novas questões.
+
+As respostas estão em seções recolhidas abaixo das questões, basta clicar nelas para expandir. Boa sorte :heart:
+
+[English](./README.md)
+[中文版本](./README-zh_CN.md)
+[Русский](./README_ru-RU.md)
+[Western Balkan](./README-bs.md)
+[Deutsch](./README-de_DE.md)
+[Tiếng Việt](./README-vi.md)
+
+
+---
+
+###### 1. Qual é a saída?
+
+```javascript
+function sayHi() {
+ console.log(name);
+ console.log(age);
+ var name = "Lydia";
+ let age = 21;
+}
+
+sayHi();
+```
+
+- A: `Lydia` e `undefined`
+- B: `Lydia` e `ReferenceError`
+- C: `ReferenceError` e `21`
+- D: `undefined` e `ReferenceError`
+
+Answer
+
+
+#### Resposta: D
+
+Dentro da função, nós primeiro declaramos a variável `name` usando a palavra-chave `var`. Isso significa que a variavel é elevada(hoisted) (O espaço na memória é separado durante a fase de criação) com o valor padrão `undefined`, até que chegue na linha onde definimos a variável. Ainda não definimos a variável na linha onde tentamos usar colocar no log o valor da variável `name`, portanto ela ainda tem o valor `undefined`.
+
+Variáveis com a palavra-chave `let` (e `const`) são elevadas, mas diferente de `var`, não são inicializadas. Elas não acessíveis antes da linha em que as declaramos (ou inicializamos). Esse é um conceito chamado de "temporal dead zone". Quando tentamos acessar essas variáveis antes de serem declaradas, o JavaScript lança um `ReferenceError`
+
+
+
+
+---
+
+###### 2. What's the output?
+
+```javascript
+for (var i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+
+for (let i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+```
+
+- A: `0 1 2` and `0 1 2`
+- B: `0 1 2` and `3 3 3`
+- C: `3 3 3` and `0 1 2`
+
+Answer
+
+
+#### Answer: C
+
+Because of the event queue in JavaScript, the `setTimeout` callback function is called _after_ the loop has been executed. Since the variable `i` in the first loop was declared using the `var` keyword, this value was global. During the loop, we incremented the value of `i` by `1` each time, using the unary operator `++`. By the time the `setTimeout` callback function was invoked, `i` was equal to `3` in the first example.
+
+In the second loop, the variable `i` was declared using the `let` keyword: variables declared with the `let` (and `const`) keyword are block-scoped (a block is anything between `{ }`). During each iteration, `i` will have a new value, and each value is scoped inside the loop.
+
+
+
+
+---
+
+###### 3. What's the output?
+
+```javascript
+const shape = {
+ radius: 10,
+ diameter() {
+ return this.radius * 2;
+ },
+ perimeter: () => 2 * Math.PI * this.radius
+};
+
+shape.diameter();
+shape.perimeter();
+```
+
+- A: `20` and `62.83185307179586`
+- B: `20` and `NaN`
+- C: `20` and `63`
+- D: `NaN` and `63`
+
+Answer
+
+
+#### Answer: B
+
+Note that the value of `diameter` is a regular function, whereas the value of `perimeter` is an arrow function.
+
+With arrow functions, the `this` keyword refers to its current surrounding scope, unlike regular functions! This means that when we call `perimeter`, it doesn't refer to the shape object, but to its surrounding scope (window for example).
+
+There is no value `radius` on that object, which returns `undefined`.
+
+
+
+
+---
+
+###### 4. What's the output?
+
+```javascript
++true;
+!"Lydia";
+```
+
+- A: `1` and `false`
+- B: `false` and `NaN`
+- C: `false` and `false`
+
+Answer
+
+
+#### Answer: A
+
+The unary plus tries to convert an operand to a number. `true` is `1`, and `false` is `0`.
+
+The string `'Lydia'` is a truthy value. What we're actually asking, is "is this truthy value falsy?". This returns `false`.
+
+
+
+
+---
+
+###### 5. Which one is true?
+
+```javascript
+const bird = {
+ size: "small"
+};
+
+const mouse = {
+ name: "Mickey",
+ small: true
+};
+```
+
+- A: `mouse.bird.size` is not valid
+- B: `mouse[bird.size]` is not valid
+- C: `mouse[bird["size"]]` is not valid
+- D: All of them are valid
+
+Answer
+
+
+#### Answer: A
+
+In JavaScript, all object keys are strings (unless it's a Symbol). Even though we might not _type_ them as strings, they are always converted into strings under the hood.
+
+JavaScript interprets (or unboxes) statements. When we use bracket notation, it sees the first opening bracket `[` and keeps going until it finds the closing bracket `]`. Only then, it will evaluate the statement.
+
+`mouse[bird.size]`: First it evaluates `bird.size`, which is `"small"`. `mouse["small"]` returns `true`
+
+However, with dot notation, this doesn't happen. `mouse` does not have a key called `bird`, which means that `mouse.bird` is `undefined`. Then, we ask for the `size` using dot notation: `mouse.bird.size`. Since `mouse.bird` is `undefined`, we're actually asking `undefined.size`. This isn't valid, and will throw an error similar to `Cannot read property "size" of undefined`.
+
+
+
+
+---
+
+---
+
+###### 6. What's the output?
+
+```javascript
+let c = { greeting: "Hey!" };
+let d;
+
+d = c;
+c.greeting = "Hello";
+console.log(d.greeting);
+```
+
+- A: `Hello`
+- B: `Hey`
+- C: `undefined`
+- D: `ReferenceError`
+- E: `TypeError`
+
+Answer
+
+
+#### Answer: A
+
+In JavaScript, all objects interact by _reference_ when setting them equal to each other.
+
+First, variable `c` holds a value to an object. Later, we assign `d` with the same reference that `c` has to the object.
+
+
+
+When you change one object, you change all of them.
+
+
+
+
+---
+
+###### 7. What's the output?
+
+```javascript
+let a = 3;
+let b = new Number(3);
+let c = 3;
+
+console.log(a == b);
+console.log(a === b);
+console.log(b === c);
+```
+
+- A: `true` `false` `true`
+- B: `false` `false` `true`
+- C: `true` `false` `false`
+- D: `false` `true` `true`
+
+Answer
+
+
+#### Answer: C
+
+`new Number()` is a built-in function constructor. Although it looks like a number, it's not really a number: it has a bunch of extra features and is an object.
+
+When we use the `==` operator, it only checks whether it has the same _value_. They both have the value of `3`, so it returns `true`.
+
+However, when we use the `===` operator, both value _and_ type should be the same. It's not: `new Number()` is not a number, it's an **object**. Both return `false.`
+
+
+
+
+---
+
+###### 8. What's the output?
+
+```javascript
+class Chameleon {
+ static colorChange(newColor) {
+ this.newColor = newColor;
+ return this.newColor;
+ }
+
+ constructor({ newColor = "green" } = {}) {
+ this.newColor = newColor;
+ }
+}
+
+const freddie = new Chameleon({ newColor: "purple" });
+freddie.colorChange("orange");
+```
+
+- A: `orange`
+- B: `purple`
+- C: `green`
+- D: `TypeError`
+
+Answer
+
+
+#### Answer: D
+
+The `colorChange` function is static. Static methods are designed to live only on the constructor in which they are created, and cannot be passed down to any children. Since `freddie` is a child, the function is not passed down, and not available on the `freddie` instance: a `TypeError` is thrown.
+
+
+
+
+---
+
+###### 9. What's the output?
+
+```javascript
+let greeting;
+greetign = {}; // Typo!
+console.log(greetign);
+```
+
+- A: `{}`
+- B: `ReferenceError: greetign is not defined`
+- C: `undefined`
+
+Answer
+
+
+#### Answer: A
+
+It logs the object, because we just created an empty object on the global object! When we mistyped `greeting` as `greetign`, the JS interpreter actually saw this as `global.greetign = {}` (or `window.greetign = {}` in a browser).
+
+In order to avoid this, we can use `"use strict"`. This makes sure that you have declared a variable before setting it equal to anything.
+
+
+
+
+---
+
+###### 10. What happens when we do this?
+
+```javascript
+function bark() {
+ console.log("Woof!");
+}
+
+bark.animal = "dog";
+```
+
+- A: Nothing, this is totally fine!
+- B: `SyntaxError`. You cannot add properties to a function this way.
+- C: `undefined`
+- D: `ReferenceError`
+
+Answer
+
+
+#### Answer: A
+
+This is possible in JavaScript, because functions are objects! (Everything besides primitive types are objects)
+
+A function is a special type of object. The code you write yourself isn't the actual function. The function is an object with properties. This property is invocable.
+
+
+
+
+---
+
+###### 11. What's the output?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const member = new Person("Lydia", "Hallie");
+Person.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+
+console.log(member.getFullName());
+```
+
+- A: `TypeError`
+- B: `SyntaxError`
+- C: `Lydia Hallie`
+- D: `undefined` `undefined`
+
+Answer
+
+
+#### Answer: A
+
+You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all objects at once, you have to use the prototype instead. So in this case,
+
+```js
+Person.prototype.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+```
+
+would have made `member.getFullName()` work. Why is this beneficial? Say that we added this method to the constructor itself. Maybe not every `Person` instance needed this method. This would waste a lot of memory space, since they would still have that property, which takes of memory space for each instance. Instead, if we only add it to the prototype, we just have it at one spot in memory, yet they all have access to it!
+
+
+
+
+---
+
+###### 12. What's the output?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const lydia = new Person("Lydia", "Hallie");
+const sarah = Person("Sarah", "Smith");
+
+console.log(lydia);
+console.log(sarah);
+```
+
+- A: `Person {firstName: "Lydia", lastName: "Hallie"}` and `undefined`
+- B: `Person {firstName: "Lydia", lastName: "Hallie"}` and `Person {firstName: "Sarah", lastName: "Smith"}`
+- C: `Person {firstName: "Lydia", lastName: "Hallie"}` and `{}`
+- D:`Person {firstName: "Lydia", lastName: "Hallie"}` and `ReferenceError`
+
+Answer
+
+
+#### Answer: A
+
+For `sarah`, we didn't use the `new` keyword. When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
+
+We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smith"`. What we actually did, is defining `global.firstName = 'Sarah'` and `global.lastName = 'Smith'`. `sarah` itself is left `undefined`.
+
+
+
+
+---
+
+###### 13. What are the three phases of event propagation?
+
+- A: Target > Capturing > Bubbling
+- B: Bubbling > Target > Capturing
+- C: Target > Bubbling > Capturing
+- D: Capturing > Target > Bubbling
+
+Answer
+
+
+#### Answer: D
+
+During the **capturing** phase, the event goes through the ancestor elements down to the target element. It then reaches the **target** element, and **bubbling** begins.
+
+
+
+
+
+
+---
+
+###### 14. All object have prototypes.
+
+- A: true
+- B: false
+
+Answer
+
+
+#### Answer: B
+
+All objects have prototypes, except for the **base object**. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
+
+
+
+
+---
+
+###### 15. What's the output?
+
+```javascript
+function sum(a, b) {
+ return a + b;
+}
+
+sum(1, "2");
+```
+
+- A: `NaN`
+- B: `TypeError`
+- C: `"12"`
+- D: `3`
+
+Answer
+
+
+#### Answer: C
+
+JavaScript is a **dynamically typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
+
+In this example, JavaScript converts the number `1` into a string, in order for the function to make sense and return a value. During the addition of a numeric type (`1`) and a string type (`'2'`), the number is treated as a string. We can concatenate strings like `"Hello" + "World"`, so what's happening here is `"1" + "2"` which returns `"12"`.
+
+
+
+
+---
+
+###### 16. What's the output?
+
+```javascript
+let number = 0;
+console.log(number++);
+console.log(++number);
+console.log(number);
+```
+
+- A: `1` `1` `2`
+- B: `1` `2` `2`
+- C: `0` `2` `2`
+- D: `0` `1` `2`
+
+Answer
+
+
+#### Answer: C
+
+The **postfix** unary operator `++`:
+
+1. Returns the value (this returns `0`)
+2. Increments the value (number is now `1`)
+
+The **prefix** unary operator `++`:
+
+1. Increments the value (number is now `2`)
+2. Returns the value (this returns `2`)
+
+This returns `0 2 2`.
+
+
+
+
+---
+
+###### 17. What's the output?
+
+```javascript
+function getPersonInfo(one, two, three) {
+ console.log(one);
+ console.log(two);
+ console.log(three);
+}
+
+const person = "Lydia";
+const age = 21;
+
+getPersonInfo`${person} is ${age} years old`;
+```
+
+- A: `"Lydia"` `21` `["", " is ", " years old"]`
+- B: `["", " is ", " years old"]` `"Lydia"` `21`
+- C: `"Lydia"` `["", " is ", " years old"]` `21`
+
+Answer
+
+
+#### Answer: B
+
+If you use tagged template literals, the value of the first argument is always an array of the string values. The remaining arguments get the values of the passed expressions!
+
+
+
+
+---
+
+###### 18. What's the output?
+
+```javascript
+function checkAge(data) {
+ if (data === { age: 18 }) {
+ console.log("You are an adult!");
+ } else if (data == { age: 18 }) {
+ console.log("You are still an adult.");
+ } else {
+ console.log(`Hmm.. You don't have an age I guess`);
+ }
+}
+
+checkAge({ age: 18 });
+```
+
+- A: `You are an adult!`
+- B: `You are still an adult.`
+- C: `Hmm.. You don't have an age I guess`
+
+Answer
+
+
+#### Answer: C
+
+When testing equality, primitives are compared by their _value_, while objects are compared by their _reference_. JavaScript checks if the objects have a reference to the same location in memory.
+
+The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
+
+This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }` return `false`.
+
+
+
+
+---
+
+###### 19. What's the output?
+
+```javascript
+function getAge(...args) {
+ console.log(typeof args);
+}
+
+getAge(21);
+```
+
+- A: `"number"`
+- B: `"array"`
+- C: `"object"`
+- D: `"NaN"`
+
+Answer
+
+
+#### Answer: C
+
+The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
+
+
+
+
+---
+
+###### 20. What's the output?
+
+```javascript
+function getAge() {
+ "use strict";
+ age = 21;
+ console.log(age);
+}
+
+getAge();
+```
+
+- A: `21`
+- B: `undefined`
+- C: `ReferenceError`
+- D: `TypeError`
+
+Answer
+
+
+#### Answer: C
+
+With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. If we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
+
+
+
+
+---
+
+###### 21. What's value of `sum`?
+
+```javascript
+const sum = eval("10*10+5");
+```
+
+- A: `105`
+- B: `"105"`
+- C: `TypeError`
+- D: `"10*10+5"`
+
+Answer
+
+
+#### Answer: A
+
+`eval` evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is `10 * 10 + 5`. This returns the number `105`.
+
+
+
+
+---
+
+###### 22. How long is cool_secret accessible?
+
+```javascript
+sessionStorage.setItem("cool_secret", 123);
+```
+
+- A: Forever, the data doesn't get lost.
+- B: When the user closes the tab.
+- C: When the user closes the entire browser, not only the tab.
+- D: When the user shuts off their computer.
+
+Answer
+
+
+#### Answer: B
+
+The data stored in `sessionStorage` is removed after closing the _tab_.
+
+If you used `localStorage`, the data would've been there forever, unless for example `localStorage.clear()` is invoked.
+
+
+
+
+---
+
+###### 23. What's the output?
+
+```javascript
+var num = 8;
+var num = 10;
+
+console.log(num);
+```
+
+- A: `8`
+- B: `10`
+- C: `SyntaxError`
+- D: `ReferenceError`
+
+Answer
+
+
+#### Answer: B
+
+With the `var` keyword, you can declare multiple variables with the same name. The variable will then hold the latest value.
+
+You cannot do this with `let` or `const` since they're block-scoped.
+
+
+
+
+---
+
+###### 24. What's the output?
+
+```javascript
+const obj = { 1: "a", 2: "b", 3: "c" };
+const set = new Set([1, 2, 3, 4, 5]);
+
+obj.hasOwnProperty("1");
+obj.hasOwnProperty(1);
+set.has("1");
+set.has(1);
+```
+
+- A: `false` `true` `false` `true`
+- B: `false` `true` `true` `true`
+- C: `true` `true` `false` `true`
+- D: `true` `true` `true` `true`
+
+Answer
+
+
+#### Answer: C
+
+All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
+
+It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')` returns `false`. It has the numeric type `1`, `set.has(1)` returns `true`.
+
+
+
+
+---
+
+###### 25. What's the output?
+
+```javascript
+const obj = { a: "one", b: "two", a: "three" };
+console.log(obj);
+```
+
+- A: `{ a: "one", b: "two" }`
+- B: `{ b: "two", a: "three" }`
+- C: `{ a: "three", b: "two" }`
+- D: `SyntaxError`
+
+Answer
+
+
+#### Answer: C
+
+If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
+
+
+
+
+---
+
+###### 26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
+
+- A: true
+- B: false
+- C: it depends
+
+Answer
+
+
+#### Answer: A
+
+The base execution context is the global execution context: it's what's accessible everywhere in your code.
+
+
+
+
+---
+
+###### 27. What's the output?
+
+```javascript
+for (let i = 1; i < 5; i++) {
+ if (i === 3) continue;
+ console.log(i);
+}
+```
+
+- A: `1` `2`
+- B: `1` `2` `3`
+- C: `1` `2` `4`
+- D: `1` `3` `4`
+
+Answer
+
+
+#### Answer: C
+
+The `continue` statement skips an iteration if a certain condition returns `true`.
+
+
+
+
+---
+
+###### 28. What's the output?
+
+```javascript
+String.prototype.giveLydiaPizza = () => {
+ return "Just give Lydia pizza already!";
+};
+
+const name = "Lydia";
+
+name.giveLydiaPizza();
+```
+
+- A: `"Just give Lydia pizza already!"`
+- B: `TypeError: not a function`
+- C: `SyntaxError`
+- D: `undefined`
+
+Answer
+
+
+#### Answer: A
+
+`String` is a built-in constructor, which we can add properties to. I just added a method to its prototype. Primitive strings are automatically converted into a string object, generated by the string prototype function. So, all strings (string objects) have access to that method!
+
+
+
+
+---
+
+###### 29. What's the output?
+
+```javascript
+const a = {};
+const b = { key: "b" };
+const c = { key: "c" };
+
+a[b] = 123;
+a[c] = 456;
+
+console.log(a[b]);
+```
+
+- A: `123`
+- B: `456`
+- C: `undefined`
+- D: `ReferenceError`
+
+Answer
+
+
+#### Answer: B
+
+Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`.
+
+However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
+
+Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to `456`, so it returns `456`.
+
+
+
+
+---
+
+###### 30. What's the output?
+
+```javascript
+const foo = () => console.log("First");
+const bar = () => setTimeout(() => console.log("Second"));
+const baz = () => console.log("Third");
+
+bar();
+foo();
+baz();
+```
+
+- A: `First` `Second` `Third`
+- B: `First` `Third` `Second`
+- C: `Second` `First` `Third`
+- D: `Second` `Third` `First`
+
+Answer
+
+
+#### Answer: B
+
+We have a `setTimeout` function and invoked it first. Yet, it was logged last.
+
+This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
+
+After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
+
+
+
+Now, `foo` gets invoked, and `"First"` is being logged.
+
+
+
+`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged.
+
+
+
+The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_.
+
+
+
+This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
+
+
+
+`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack.
+
+
+
+
+---
+
+###### 31. What is the event.target when clicking the button?
+
+```html
+
+```
+
+- A: Outer `div`
+- B: Inner `div`
+- C: `button`
+- D: An array of all nested elements.
+
+Answer
+
+
+#### Answer: C
+
+The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+
+
+
+
+---
+
+###### 32. When you click the paragraph, what's the logged output?
+
+```html
+
+```
+
+- A: `p` `div`
+- B: `div` `p`
+- C: `p`
+- D: `div`
+
+Answer
+
+
+#### Answer: A
+
+If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
+
+
+
+
+---
+
+###### 33. What's the output?
+
+```javascript
+const person = { name: "Lydia" };
+
+function sayHi(age) {
+ console.log(`${this.name} is ${age}`);
+}
+
+sayHi.call(person, 21);
+sayHi.bind(person, 21);
+```
+
+- A: `undefined is 21` `Lydia is 21`
+- B: `function` `function`
+- C: `Lydia is 21` `Lydia is 21`
+- D: `Lydia is 21` `function`
+
+Answer
+
+
+#### Answer: D
+
+With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
+
+`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
+
+
+
+
+---
+
+###### 34. What's the output?
+
+```javascript
+function sayHi() {
+ return (() => 0)();
+}
+
+typeof sayHi();
+```
+
+- A: `"object"`
+- B: `"number"`
+- C: `"function"`
+- D: `"undefined"`
+
+Answer
+
+
+#### Answer: B
+
+The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+
+FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+
+
+
+
+---
+
+###### 35. Which of these values are falsy?
+
+```javascript
+0;
+new Number(0);
+("");
+(" ");
+new Boolean(false);
+undefined;
+```
+
+- A: `0`, `''`, `undefined`
+- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
+- C: `0`, `''`, `new Boolean(false)`, `undefined`
+- D: All of them are falsy
+
+Answer
+
+
+#### Answer: A
+
+There are only six falsy values:
+
+- `undefined`
+- `null`
+- `NaN`
+- `0`
+- `''` (empty string)
+- `false`
+
+Function constructors, like `new Number` and `new Boolean` are truthy.
+
+
+
+
+---
+
+###### 36. What's the output?
+
+```javascript
+console.log(typeof typeof 1);
+```
+
+- A: `"number"`
+- B: `"string"`
+- C: `"object"`
+- D: `"undefined"`
+
+Answer
+
+
+#### Answer: B
+
+`typeof 1` returns `"number"`.
+`typeof "number"` returns `"string"`
+
+
+
+
+---
+
+###### 37. What's the output?
+
+```javascript
+const numbers = [1, 2, 3];
+numbers[10] = 11;
+console.log(numbers);
+```
+
+- A: `[1, 2, 3, 7 x null, 11]`
+- B: `[1, 2, 3, 11]`
+- C: `[1, 2, 3, 7 x empty, 11]`
+- D: `SyntaxError`
+
+Answer
+
+
+#### Answer: C
+
+When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like:
+
+`[1, 2, 3, 7 x empty, 11]`
+
+depending on where you run it (it's different for every browser, node, etc.)
+
+
+
+
+---
+
+###### 38. What's the output?
+
+```javascript
+(() => {
+ let x, y;
+ try {
+ throw new Error();
+ } catch (x) {
+ (x = 1), (y = 2);
+ console.log(x);
+ }
+ console.log(x);
+ console.log(y);
+})();
+```
+
+- A: `1` `undefined` `2`
+- B: `undefined` `undefined` `undefined`
+- C: `1` `1` `2`
+- D: `1` `undefined` `undefined`
+
+Answer
+
+
+#### Answer: A
+
+The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
+
+Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+
+Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+
+
+
+
+---
+
+###### 39. Everything in JavaScript is either a...
+
+- A: primitive or object
+- B: function or object
+- C: trick question! only objects
+- D: number or object
+
+Answer
+
+
+#### Answer: A
+
+JavaScript only has primitive types and objects.
+
+Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+
+What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+
+
+
+
+---
+
+###### 40. What's the output?
+
+```javascript
+[[0, 1], [2, 3]].reduce(
+ (acc, cur) => {
+ return acc.concat(cur);
+ },
+ [1, 2]
+);
+```
+
+- A: `[0, 1, 2, 3, 1, 2]`
+- B: `[6, 1, 2]`
+- C: `[1, 2, 0, 1, 2, 3]`
+- D: `[1, 2, 6]`
+
+Answer
+
+
+#### Answer: C
+
+`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
+
+Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
+
+
+
+
+---
+
+###### 41. What's the output?
+
+```javascript
+!!null;
+!!"";
+!!1;
+```
+
+- A: `false` `true` `false`
+- B: `false` `false` `true`
+- C: `false` `true` `true`
+- D: `true` `true` `false`
+
+Answer
+
+
+#### Answer: B
+
+`null` is falsy. `!null` returns `true`. `!true` returns `false`.
+
+`""` is falsy. `!""` returns `true`. `!true` returns `false`.
+
+`1` is truthy. `!1` returns `false`. `!false` returns `true`.
+
+
+
+
+---
+
+###### 42. What does the `setInterval` method return in the browser?
+
+```javascript
+setInterval(() => console.log("Hi"), 1000);
+```
+
+- A: a unique id
+- B: the amount of milliseconds specified
+- C: the passed function
+- D: `undefined`
+
+Answer
+
+
+#### Answer: A
+
+It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function.
+
+
+
+
+---
+
+###### 43. What does this return?
+
+```javascript
+[..."Lydia"];
+```
+
+- A: `["L", "y", "d", "i", "a"]`
+- B: `["Lydia"]`
+- C: `[[], "Lydia"]`
+- D: `[["L", "y", "d", "i", "a"]]`
+
+Answer
+
+
+#### Answer: A
+
+A string is an iterable. The spread operator maps every character of an iterable to one element.
+
+
+
From 967481a4c47fb7fba3c538d169fb2cd981f13014 Mon Sep 17 00:00:00 2001
From: Guilherme Nogara
Date: Wed, 19 Jun 2019 20:39:48 -0300
Subject: [PATCH 013/881] Questions 1-3 done
---
README_pt_BR.md | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/README_pt_BR.md b/README_pt_BR.md
index 6c3cfd85..3a6f20de 100644
--- a/README_pt_BR.md
+++ b/README_pt_BR.md
@@ -34,7 +34,7 @@ sayHi();
- C: `ReferenceError` e `21`
- D: `undefined` e `ReferenceError`
-Answer
+Resposta
#### Resposta: D
@@ -48,7 +48,7 @@ Variáveis com a palavra-chave `let` (e `const`) são elevadas, mas diferente de
---
-###### 2. What's the output?
+###### 2. Qual é a saída?
```javascript
for (var i = 0; i < 3; i++) {
@@ -60,25 +60,25 @@ for (let i = 0; i < 3; i++) {
}
```
-- A: `0 1 2` and `0 1 2`
-- B: `0 1 2` and `3 3 3`
-- C: `3 3 3` and `0 1 2`
+- A: `0 1 2` e `0 1 2`
+- B: `0 1 2` e `3 3 3`
+- C: `3 3 3` e `0 1 2`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-Because of the event queue in JavaScript, the `setTimeout` callback function is called _after_ the loop has been executed. Since the variable `i` in the first loop was declared using the `var` keyword, this value was global. During the loop, we incremented the value of `i` by `1` each time, using the unary operator `++`. By the time the `setTimeout` callback function was invoked, `i` was equal to `3` in the first example.
+Por causa da fila de eventos em JavaScript, a callback de `setTimeout` é chamada depois do laço ter sido executado. Já que a variável `i` no primeiro laço foi declarada usando a palavra-chave `var`, seu valor era global. Durante o laço, incrementamos o valor de `i` por `1` em cada repetição, usando o operador unário `++`. Quando a callback de `setTimeout` foi chamada, `i` valia `3`.
-In the second loop, the variable `i` was declared using the `let` keyword: variables declared with the `let` (and `const`) keyword are block-scoped (a block is anything between `{ }`). During each iteration, `i` will have a new value, and each value is scoped inside the loop.
+No segundo laço, a variável `i` foi declarada usando a palavra-chave `let`: Variáveis declaradas com `let` (e `const`) só são acessíveis nos escopos de seus blocos (um bloco é qualquer código entre `{ }`). Durante cada repetição do laço, `i` vai ter um novo valor, e cada valor tem seu escopo dentro do laço.
---
-###### 3. What's the output?
+###### 3. Qual é a saída?
```javascript
const shape = {
@@ -93,21 +93,21 @@ shape.diameter();
shape.perimeter();
```
-- A: `20` and `62.83185307179586`
-- B: `20` and `NaN`
-- C: `20` and `63`
-- D: `NaN` and `63`
+- A: `20` e `62.83185307179586`
+- B: `20` e `NaN`
+- C: `20` e `63`
+- D: `NaN` e `63`
-Answer
+Resposta
-#### Answer: B
+#### Resposta: B
-Note that the value of `diameter` is a regular function, whereas the value of `perimeter` is an arrow function.
+Perceba que o valor de `diameter` é uma função normal, enquanto que o valor de `perimeter` é uma arrow function.
-With arrow functions, the `this` keyword refers to its current surrounding scope, unlike regular functions! This means that when we call `perimeter`, it doesn't refer to the shape object, but to its surrounding scope (window for example).
+Com arrow functions, a palavra-chave `this` faz referência ao escopo atual em que está inserida, diferente de funções normais! Isso significa que quando nós chamamos `perimeter`, ela não faz referência ao objeto shape, mas ao seu escopo atual (por exemplo, window).
-There is no value `radius` on that object, which returns `undefined`.
+Não há `radius` fora de shape, então retorna `undefined`.
From b6fa9fbe0280ab967127ce9c5383255801b749dc Mon Sep 17 00:00:00 2001
From: Guilherme Nogara
Date: Wed, 19 Jun 2019 20:39:48 -0300
Subject: [PATCH 014/881] Questions 1-3 done
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[english] e [中文版本] tem quebra de linha entre os dois.
---
README_pt_BR.md | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/README_pt_BR.md b/README_pt_BR.md
index 6c3cfd85..60b85219 100644
--- a/README_pt_BR.md
+++ b/README_pt_BR.md
@@ -6,7 +6,7 @@ Do básico ao avançado: Teste quão bem você conhece o JavaScript, refresce um
As respostas estão em seções recolhidas abaixo das questões, basta clicar nelas para expandir. Boa sorte :heart:
-[English](./README.md)
+[English](./README.md)
[中文版本](./README-zh_CN.md)
[Русский](./README_ru-RU.md)
[Western Balkan](./README-bs.md)
@@ -34,7 +34,7 @@ sayHi();
- C: `ReferenceError` e `21`
- D: `undefined` e `ReferenceError`
-Answer
+Resposta
#### Resposta: D
@@ -48,7 +48,7 @@ Variáveis com a palavra-chave `let` (e `const`) são elevadas, mas diferente de
---
-###### 2. What's the output?
+###### 2. Qual é a saída?
```javascript
for (var i = 0; i < 3; i++) {
@@ -60,25 +60,25 @@ for (let i = 0; i < 3; i++) {
}
```
-- A: `0 1 2` and `0 1 2`
-- B: `0 1 2` and `3 3 3`
-- C: `3 3 3` and `0 1 2`
+- A: `0 1 2` e `0 1 2`
+- B: `0 1 2` e `3 3 3`
+- C: `3 3 3` e `0 1 2`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-Because of the event queue in JavaScript, the `setTimeout` callback function is called _after_ the loop has been executed. Since the variable `i` in the first loop was declared using the `var` keyword, this value was global. During the loop, we incremented the value of `i` by `1` each time, using the unary operator `++`. By the time the `setTimeout` callback function was invoked, `i` was equal to `3` in the first example.
+Por causa da fila de eventos em JavaScript, a callback de `setTimeout` é chamada depois do laço ter sido executado. Já que a variável `i` no primeiro laço foi declarada usando a palavra-chave `var`, seu valor era global. Durante o laço, incrementamos o valor de `i` por `1` em cada repetição, usando o operador unário `++`. Quando a callback de `setTimeout` foi chamada, `i` valia `3`.
-In the second loop, the variable `i` was declared using the `let` keyword: variables declared with the `let` (and `const`) keyword are block-scoped (a block is anything between `{ }`). During each iteration, `i` will have a new value, and each value is scoped inside the loop.
+No segundo laço, a variável `i` foi declarada usando a palavra-chave `let`: Variáveis declaradas com `let` (e `const`) só são acessíveis nos escopos de seus blocos (um bloco é qualquer código entre `{ }`). Durante cada repetição do laço, `i` vai ter um novo valor, e cada valor tem seu escopo dentro do laço.
---
-###### 3. What's the output?
+###### 3. Qual é a saída?
```javascript
const shape = {
@@ -93,21 +93,21 @@ shape.diameter();
shape.perimeter();
```
-- A: `20` and `62.83185307179586`
-- B: `20` and `NaN`
-- C: `20` and `63`
-- D: `NaN` and `63`
+- A: `20` e `62.83185307179586`
+- B: `20` e `NaN`
+- C: `20` e `63`
+- D: `NaN` e `63`
-Answer
+Resposta
-#### Answer: B
+#### Resposta: B
-Note that the value of `diameter` is a regular function, whereas the value of `perimeter` is an arrow function.
+Perceba que o valor de `diameter` é uma função normal, enquanto que o valor de `perimeter` é uma arrow function.
-With arrow functions, the `this` keyword refers to its current surrounding scope, unlike regular functions! This means that when we call `perimeter`, it doesn't refer to the shape object, but to its surrounding scope (window for example).
+Com arrow functions, a palavra-chave `this` faz referência ao escopo atual em que está inserida, diferente de funções normais! Isso significa que quando nós chamamos `perimeter`, ela não faz referência ao objeto shape, mas ao seu escopo atual (por exemplo, window).
-There is no value `radius` on that object, which returns `undefined`.
+Não há `radius` fora de shape, então retorna `undefined`.
From c1add6d66c9e09da325e6cb13320a1cdb2a09848 Mon Sep 17 00:00:00 2001
From: zeayal
Date: Thu, 20 Jun 2019 10:12:43 +0800
Subject: [PATCH 015/881] Update README-zh_CN.md
remove extra symbol.
---
README-zh_CN.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README-zh_CN.md b/README-zh_CN.md
index bc21b456..770a6eb5 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -1270,7 +1270,7 @@ setInterval(() => console.log('Hi'), 1000)
###### 43. 输出是什么?
```javascript
-;[...'Lydia']
+[...'Lydia']
```
- A: `["L", "y", "d", "i", "a"]`
From 6199ad7207509e48056c2558372a960be553754b Mon Sep 17 00:00:00 2001
From: Do Trung Kien
Date: Thu, 20 Jun 2019 09:23:57 +0700
Subject: [PATCH 016/881] correct typo and improve tranlation
---
README-vi.md | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/README-vi.md b/README-vi.md
index b9b7c3be..d38d7a35 100644
--- a/README-vi.md
+++ b/README-vi.md
@@ -439,8 +439,9 @@ Tất cả các object đều có prototypes, ngoại trừ **base object**. Obj
- ---
+
+---
###### 15. Ouput là gì?
@@ -859,7 +860,6 @@ console.log(a[b]);
Object keys sẽ tự động được convert sang dạng string. Chúng ta đang set một object như là một key cho object `a`, với giá trị là `123`.
-However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
Tuy nhiên khi ta string hóa một object, nó sẽ trở thành `"[Object object]"`. Nên tại đây phép gán này thực chất chính là `a["Object object"] = 123`. Phép gán tiếp theo cũng giống hệt vậy. `c` là một object khác mà chúng ta đang string hóa nó. Theo đó, `a["Object object"] = 456`.
Cuối cùng khi gọi `a[b]`, thực chất chính là gọi `a["Object object"]`. Giá trị của nó là `456`, nên trả về là `456`.
@@ -915,7 +915,7 @@ WebAPI không thể thêm thứ gì đó vào stack cho tới khi nó được s
-`bar` được gọi, `"Second"` được log ra, và nó được đưa ra khói stack.
+`bar` được gọi, `"Second"` được log ra, và nó được đưa ra khỏi stack.
@@ -1053,7 +1053,7 @@ undefined;
- A: `0`, `''`, `undefined`
- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
- C: `0`, `''`, `new Boolean(false)`, `undefined`
-- D: All of them are falsy
+- D: Tất cả đều là falsy
Đáp án
@@ -1210,7 +1210,6 @@ Primitive types là `boolean`, `null`, `undefined`, `bigint`, `number`, `string`
#### Đáp án: C
-`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
`[1, 2]` là giá trị khởi tạo. Đây là giá trị chúng ta bắt đầu, và cũng là giá trị đầu tiên của `acc`. Tại vòng đầu tiên, `acc` là `[1,2]`, và `cur` là `[0, 1]`. Ta nối chúng lại tạo ra `[1, 2, 0, 1]`.
Tiếp tục, `[1, 2, 0, 1]` là `acc` và `[2, 3]` là `cur`. Ta nối chúng lại tạo ra `[1, 2, 0, 1, 2, 3]`.
From 3e26a20c59865a56fbb286959a60a8a0a4c84b75 Mon Sep 17 00:00:00 2001
From: fanfan1609
Date: Thu, 20 Jun 2019 12:01:31 +0900
Subject: [PATCH 017/881] Update README-vi.md
Update question 13.
---
README-vi.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README-vi.md b/README-vi.md
index b9b7c3be..ba3fa2d0 100644
--- a/README-vi.md
+++ b/README-vi.md
@@ -404,7 +404,7 @@ Chúng ta cho rằng `this.firstName` là `"Sarah"` và `this.lastName` là `"Sm
---
-###### 13. What are the three phases of event propagation?
+###### 13. 3 giai đoạn của event propagation là gì?
- A: Target > Capturing > Bubbling
- B: Bubbling > Target > Capturing
From 6e5415c67386c680478469c2cacc485dfe218a0d Mon Sep 17 00:00:00 2001
From: Guilherme Nogara
Date: Thu, 20 Jun 2019 01:12:58 -0300
Subject: [PATCH 018/881] 3-15 done
---
README_pt_BR.md | 142 +++++++++++++++++++++++++-----------------------
1 file changed, 73 insertions(+), 69 deletions(-)
diff --git a/README_pt_BR.md b/README_pt_BR.md
index 60b85219..0c5ab777 100644
--- a/README_pt_BR.md
+++ b/README_pt_BR.md
@@ -114,7 +114,7 @@ Não há `radius` fora de shape, então retorna `undefined`.
---
-###### 4. What's the output?
+###### 4. Qual é a saída?
```javascript
+true;
@@ -125,21 +125,22 @@ Não há `radius` fora de shape, então retorna `undefined`.
- B: `false` and `NaN`
- C: `false` and `false`
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-The unary plus tries to convert an operand to a number. `true` is `1`, and `false` is `0`.
+O operador unário `+` tenta converter um operando para um número. `true` é `1`, e `false` é `0`.
-The string `'Lydia'` is a truthy value. What we're actually asking, is "is this truthy value falsy?". This returns `false`.
+A string `'Lydia'` tem valor truthy*. O que estamos realmente perguntando é "Esse valor truthy é falsy?". Isso retorna `false`.
+###### *Nota do tradutor: truthy é um termo único ao JavaScript que denota valores que podem ser convertidos em um booleano `True`. Sua contraparte é falsey, que são valores que podem ser convertidos em um booleano `false`. Para fins de consistência, mantenho os termos originais.
---
-###### 5. Which one is true?
+###### 5. Qual é a alternativa correta?
```javascript
const bird = {
@@ -152,23 +153,23 @@ const mouse = {
};
```
-- A: `mouse.bird.size` is not valid
-- B: `mouse[bird.size]` is not valid
-- C: `mouse[bird["size"]]` is not valid
-- D: All of them are valid
+- A: `mouse.bird.size` não é válido
+- B: `mouse[bird.size]` não é válido
+- C: `mouse[bird["size"]]` não é válido
+- D: Todos são válidos
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-In JavaScript, all object keys are strings (unless it's a Symbol). Even though we might not _type_ them as strings, they are always converted into strings under the hood.
+No JavaScript, todas chaves dos objetos são strings (a não ser que sejam um símbolo). Ainda que não possamos digitá-las como strings, elas são sempre convertidas para string sob o capô.
-JavaScript interprets (or unboxes) statements. When we use bracket notation, it sees the first opening bracket `[` and keeps going until it finds the closing bracket `]`. Only then, it will evaluate the statement.
+JavaScript interpreta afirmações. Quando usamos a notação de colchetes, ele vê o colchete de abertura `[` e continua lendo até encontrar o colchete que o fecha `]`. Só então vai avaliar e rodar as afirmações.
-`mouse[bird.size]`: First it evaluates `bird.size`, which is `"small"`. `mouse["small"]` returns `true`
+`mouse[bird.size]`: Primeiro avalia `bird.size`, que é `"small"`. `mouse["small"]` retorna `true`
-However, with dot notation, this doesn't happen. `mouse` does not have a key called `bird`, which means that `mouse.bird` is `undefined`. Then, we ask for the `size` using dot notation: `mouse.bird.size`. Since `mouse.bird` is `undefined`, we're actually asking `undefined.size`. This isn't valid, and will throw an error similar to `Cannot read property "size" of undefined`.
+Por outro lado, com a notação de ponto `.`, isso não acontece. `mouse` não tem uma chave chamada `bird`, o que significa que `mouse.bird` é `undefined`. Então, pedimos pelo `size` usando a notação de ponto: `mouse.bird.size`. Uma vez que `mouse.bird` é `undefined`, estamos realmente pedindo `undefined.size`. Isso não é válido, e irá gerar um erro similar a `Cannot read property "size" of undefined`.
@@ -177,7 +178,7 @@ However, with dot notation, this doesn't happen. `mouse` does not have a key cal
---
-###### 6. What's the output?
+###### 6. Quais são as saídas?
```javascript
let c = { greeting: "Hey!" };
@@ -194,25 +195,25 @@ console.log(d.greeting);
- D: `ReferenceError`
- E: `TypeError`
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-In JavaScript, all objects interact by _reference_ when setting them equal to each other.
+Em JavaScript, todos objetos interagem por referência quando os colocamos um igual ao outro.
-First, variable `c` holds a value to an object. Later, we assign `d` with the same reference that `c` has to the object.
+Primeiro, a variável `c` guarda o valor de um objeto. Depois, declaramos `d` com a mesma referencia que `c` tem para o objeto.
-When you change one object, you change all of them.
+Quando você muda um objeto, você muda todos eles.
---
-###### 7. What's the output?
+###### 7. Qual é a saída?
```javascript
let a = 3;
@@ -229,23 +230,23 @@ console.log(b === c);
- C: `true` `false` `false`
- D: `false` `true` `true`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-`new Number()` is a built-in function constructor. Although it looks like a number, it's not really a number: it has a bunch of extra features and is an object.
+`new Number()` é uma funcção construtura padrão do JavaScript. Ainda que parece com um número, não é realmente um número: Tem um monte de funções extras e é um objeto.
-When we use the `==` operator, it only checks whether it has the same _value_. They both have the value of `3`, so it returns `true`.
+Quando usamos o operador `==`, só conferimos se ambas tem o mesmo valor. Ambas tem o valor de `3`, então retorna `true`.
-However, when we use the `===` operator, both value _and_ type should be the same. It's not: `new Number()` is not a number, it's an **object**. Both return `false.`
+Contudo, quando usamos o operador `===`, ambos valor e tipo tem de ser o mesmo. E não é: `new Number()` não é um número, é um **objeto**. Ambos retornam `false`.
---
-###### 8. What's the output?
+###### 8. Qual é a saída?
```javascript
class Chameleon {
@@ -268,23 +269,24 @@ freddie.colorChange("orange");
- C: `green`
- D: `TypeError`
-Answer
+Resposta
-#### Answer: D
+#### Resposta: D
-The `colorChange` function is static. Static methods are designed to live only on the constructor in which they are created, and cannot be passed down to any children. Since `freddie` is a child, the function is not passed down, and not available on the `freddie` instance: a `TypeError` is thrown.
+A função `colorChange` é estática. Métodos estáticos são designados para viver somente nos construtores em que são criados, e filhos não herdam esses métodos.
+Já que `freddie` é filho de `Chameleon`, a função não é herdada, e não está disponível para `freddie`: Um erro `TypeError` é gerado.
---
-###### 9. What's the output?
+###### 9. Qual é a saída?
```javascript
let greeting;
-greetign = {}; // Typo!
+greetign = {}; // Erro de digitação!
console.log(greetign);
```
@@ -292,21 +294,21 @@ console.log(greetign);
- B: `ReferenceError: greetign is not defined`
- C: `undefined`
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-It logs the object, because we just created an empty object on the global object! When we mistyped `greeting` as `greetign`, the JS interpreter actually saw this as `global.greetign = {}` (or `window.greetign = {}` in a browser).
+Cria o log do objeto, pois criamos um objeto vazio no objeto global! Quando erramos a digitação de `greeting` como `greetign`, o interpretador do JavaScript viu isso como `global.greetign = {}` (ou `window.greetign = {}` em um navegador).
-In order to avoid this, we can use `"use strict"`. This makes sure that you have declared a variable before setting it equal to anything.
+Para evitar esse comportamento, podemos usar `"use strict"`. Isso garante que você tenha declarado uma variável antes de poder inicializá-la com algum valor.
---
-###### 10. What happens when we do this?
+###### 10. O que acontece quando fazemos isso?
```javascript
function bark() {
@@ -316,26 +318,26 @@ function bark() {
bark.animal = "dog";
```
-- A: Nothing, this is totally fine!
-- B: `SyntaxError`. You cannot add properties to a function this way.
+- A: Nada, isso é ok!
+- B: `SyntaxError`. Não se pode adicionar propriedades em uma função dessa maneira.
- C: `undefined`
- D: `ReferenceError`
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-This is possible in JavaScript, because functions are objects! (Everything besides primitive types are objects)
+Isso é possível em JavaScript, pois funções são objetos! (Tudo menos tipos primitivos são objetos)
-A function is a special type of object. The code you write yourself isn't the actual function. The function is an object with properties. This property is invocable.
+Uma função é um tipo especial de objeto. O código que você escreve não é a verdadeira função. A função é um objeto com propriedades. E essa propriedade é invocável.
---
-###### 11. What's the output?
+###### 11. Qual é a saída?
```javascript
function Person(firstName, lastName) {
@@ -356,12 +358,14 @@ console.log(member.getFullName());
- C: `Lydia Hallie`
- D: `undefined` `undefined`
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
+
+Você não pode adicionar propriedades para um construtor igual aos objetos normais. Se você quer adicionar uma funcionalidade para todos objetos ao mesmo tempo, você deve usar o prototype.
-You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all objects at once, you have to use the prototype instead. So in this case,
+Então nesse caso
```js
Person.prototype.getFullName = function() {
@@ -369,14 +373,14 @@ Person.prototype.getFullName = function() {
};
```
-would have made `member.getFullName()` work. Why is this beneficial? Say that we added this method to the constructor itself. Maybe not every `Person` instance needed this method. This would waste a lot of memory space, since they would still have that property, which takes of memory space for each instance. Instead, if we only add it to the prototype, we just have it at one spot in memory, yet they all have access to it!
+faria `member.getFullName()` funcionar. Por quê isso é beneficial? Digamos que tivéssemos esse método ao próprio construtor. Talvez nem toda instância de `Person` precisasse desse método. Isso gastaria muita memória, uma vez que cada instância teria esse propriedade e teria seu espaço alocado. Ao invés disso, se adicionarmos somente ao protótipo, alocamos somente um único espaço na memória, e todas instâncias de `Person`ainda tem acesso ao método.
---
-###### 12. What's the output?
+###### 12. Qual é a saída?
```javascript
function Person(firstName, lastName) {
@@ -391,38 +395,38 @@ console.log(lydia);
console.log(sarah);
```
-- A: `Person {firstName: "Lydia", lastName: "Hallie"}` and `undefined`
-- B: `Person {firstName: "Lydia", lastName: "Hallie"}` and `Person {firstName: "Sarah", lastName: "Smith"}`
-- C: `Person {firstName: "Lydia", lastName: "Hallie"}` and `{}`
-- D:`Person {firstName: "Lydia", lastName: "Hallie"}` and `ReferenceError`
+- A: `Person {firstName: "Lydia", lastName: "Hallie"}` e `undefined`
+- B: `Person {firstName: "Lydia", lastName: "Hallie"}` e `Person {firstName: "Sarah", lastName: "Smith"}`
+- C: `Person {firstName: "Lydia", lastName: "Hallie"}` e `{}`
+- D:`Person {firstName: "Lydia", lastName: "Hallie"}` e `ReferenceError`
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-For `sarah`, we didn't use the `new` keyword. When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
+Na `sarah`, não usamos a palavra-chave `new`. Quando usamos `new`, se refere ao novo objeto vazio que criamos. Contudo, se não usarmos `new`, nos referimos ao **objeto global**!
-We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smith"`. What we actually did, is defining `global.firstName = 'Sarah'` and `global.lastName = 'Smith'`. `sarah` itself is left `undefined`.
+Afirmamos que `this.firstName` vale `"Sarah"` e `this.lastName` vale `"Smith"`. O que realmente fizemos foi definir `global.firstName = 'Sarah'` e `global.lastName = 'Smith'`. A `sarah` ainda é `undefined`.
---
-###### 13. What are the three phases of event propagation?
+###### 13. Quais são as três fases na propagação de eventos?
- A: Target > Capturing > Bubbling
- B: Bubbling > Target > Capturing
- C: Target > Bubbling > Capturing
- D: Capturing > Target > Bubbling
-Answer
+Resposta
-#### Answer: D
+#### Resposta: D
-During the **capturing** phase, the event goes through the ancestor elements down to the target element. It then reaches the **target** element, and **bubbling** begins.
+Durate a fase do **capturing**, o evento percorre os elementos pais até chegar no elemento algo. Isso alcança o elemento **target**, e o **bubbling** começa.
@@ -431,17 +435,17 @@ During the **capturing** phase, the event goes through the ancestor elements dow
---
-###### 14. All object have prototypes.
+###### 14. Todos objetos tem protótipos.
-- A: true
-- B: false
+- A: Verdadeiro
+- B: Falso
-Answer
+Resposta
-#### Answer: B
+#### Resposta: B
-All objects have prototypes, except for the **base object**. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
+Todos objetos tem protótipos, exceto pelo **base object**. O base object tem acesso à alguns métodos e propriedades, como `.toString`. É o motivo de podermos usar métodos já embutidos no JavaScript! Todos métodos desse tipo já estão embutidos no protótipo. Apesar do JavaScript não encontrar algum método diretamente no seu objeto, ele percorre a cadeia de protótipos até encontrar no base, o que torna acessível para todo objeto.
From 762072e0a73e71352c513496ef1e71bf8d86ecc2 Mon Sep 17 00:00:00 2001
From: Alexander Ivanov
Date: Thu, 20 Jun 2019 07:24:47 +0300
Subject: [PATCH 019/881] Add edits
---
README_ru-RU.md | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index a4eb0829..690d4bf0 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -2,12 +2,16 @@
Я ежедевно публикую вопросы по JavaScript с вариантами ответов в своем [Instagram](https://www.instagram.com/theavocoder), которые дублируются в этом репозитории.
-От азов к сложным вопросам: провеь как хорошо ты знаешь JavaScript, освежи свои знания или приготовься к собеседованию! :muscle: :rocket: Я дополняю этот репозиторий каждую неделю новыми вопросами.
+От азов к сложным вопросам: проверь, как хорошо ты знаешь JavaScript, освежи свои знания или приготовься к собеседованию! :muscle: :rocket: Я дополняю этот репозиторий каждую неделю новыми вопросами.
-Ответы находятся в свернутой секции ниже вопросов. Просто нажми на ответ, чтобы развернуть. Удачи! :heart:
+Ответы находятся в свернутой секции ниже вопросов. Просто нажми на "Ответ", чтобы развернуть. Удачи! :heart:
-[中文版本](./README-zh_CN.md)
+[中文版本](./README-zh_CN.md)
[Русский](./README_ru-RU.md)
+[Western Balkan](./README-bs.md)
+[Deutsch](./README-de_DE.md)
+[Tiếng Việt](./README-vi.md)
+
---
@@ -1212,7 +1216,6 @@ console.log(numbers);
`[1, 2]` - начальное значение, с которым инициализируется переменная `acc`. После первого прохода `acc` будет равно `[1,2]`, а `cur` будет `[0,1]`. После конкатенации результат будет `[1, 2, 0, 1]`.
-
Затем `acc` равно `[1, 2, 0, 1]`, а `cur` равно `[2, 3]`. После слияния получим `[1, 2, 0, 1, 2, 3]`.
From bdc27a8684193cfe1812c34f45babeff17702060 Mon Sep 17 00:00:00 2001
From: Dima Yavorskiy <33015386+yavorskiydima@users.noreply.github.com>
Date: Thu, 20 Jun 2019 09:24:53 +0500
Subject: [PATCH 020/881] ru-syntax-errors
---
README_ru-RU.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index a4eb0829..a63b6545 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -1,8 +1,8 @@
# Список (продвинутых) вопросов по JavaScript
-Я ежедевно публикую вопросы по JavaScript с вариантами ответов в своем [Instagram](https://www.instagram.com/theavocoder), которые дублируются в этом репозитории.
+Я ежедневно публикую вопросы по JavaScript с вариантами ответов в своем [Instagram](https://www.instagram.com/theavocoder), которые дублируются в этом репозитории.
-От азов к сложным вопросам: провеь как хорошо ты знаешь JavaScript, освежи свои знания или приготовься к собеседованию! :muscle: :rocket: Я дополняю этот репозиторий каждую неделю новыми вопросами.
+От азов к сложным вопросам: проверь как хорошо ты знаешь JavaScript, освежи свои знания или приготовься к собеседованию! :muscle: :rocket: Я дополняю этот репозиторий каждую неделю новыми вопросами.
Ответы находятся в свернутой секции ниже вопросов. Просто нажми на ответ, чтобы развернуть. Удачи! :heart:
From c8b5e24b3869f6f000c9270e0f7950b97af795a6 Mon Sep 17 00:00:00 2001
From: Alexander Ivanov
Date: Thu, 20 Jun 2019 07:34:21 +0300
Subject: [PATCH 021/881] Fix a typo
Signed-off-by: Alexander Ivanov
---
README_ru-RU.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index 690d4bf0..369e90d7 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -1,6 +1,6 @@
# Список (продвинутых) вопросов по JavaScript
-Я ежедевно публикую вопросы по JavaScript с вариантами ответов в своем [Instagram](https://www.instagram.com/theavocoder), которые дублируются в этом репозитории.
+Я ежедневно публикую вопросы по JavaScript с вариантами ответов в своем [Instagram](https://www.instagram.com/theavocoder), которые дублируются в этом репозитории.
От азов к сложным вопросам: проверь, как хорошо ты знаешь JavaScript, освежи свои знания или приготовься к собеседованию! :muscle: :rocket: Я дополняю этот репозиторий каждую неделю новыми вопросами.
From 72307bf0cc7beb985c3527aafabdc039081c1520 Mon Sep 17 00:00:00 2001
From: Dima Yavorskiy <33015386+yavorskiydima@users.noreply.github.com>
Date: Thu, 20 Jun 2019 09:38:32 +0500
Subject: [PATCH 022/881] typo 2
---
README_ru-RU.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index a63b6545..1dc9bafe 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -34,7 +34,7 @@ sayHi();
#### Ответ: D
-Внутри функции мы сперва определям переменную `name` с помощью ключевого слова `var`. Это означает, что переменная будет поднята (область памяти под переменную будет выделена во время фазы создания) со значением `undefined` по умолчанию, до тех пора пока исполнение кода не дойдет до строчки, где определяется переменная. Мы еще не определили значение `name` когда пытаемся вывести её в консоль, поэтому в консоли будет `undefined`.
+Внутри функции мы сперва определяем переменную `name` с помощью ключевого слова `var`. Это означает, что переменная будет поднята (область памяти под переменную будет выделена во время фазы создания) со значением `undefined` по умолчанию, до тех пора пока исполнение кода не дойдет до строчки, где определяется переменная. Мы еще не определили значение `name` когда пытаемся вывести её в консоль, поэтому в консоли будет `undefined`.
Переменные, определенные с помощью `let` (и `const`), также поднимаются, но в отличие от `var`, не инициализируются. Доступ к ним не возможен до тех пор, пока не выполнится строка их определения (инициализации). Это называется "временная мертвая зона". Когда мы пытаемся обратиться к переменным до того момента как они определены, JavaScript выбрасывает исключение `ReferenceError`.
@@ -232,7 +232,7 @@ console.log(b === c);
Оператор `==` разрешает приведение типов, он проверяет равенство _значений_. Оба значения равны `3`, поэтому возвращается `true`.
-При использвании оператора `===` значение _и_ тип должны быть одинаковыми. Но в нашем случае это не так: `new Number()` это не число, это **объект**. Оба возвращают `false`.
+При использовании оператора `===` значение _и_ тип должны быть одинаковыми. Но в нашем случае это не так: `new Number()` это не число, это **объект**. Оба возвращают `false`.
@@ -426,7 +426,7 @@ console.log(sarah);
---
-###### 14. Все объекты имют прототипы
+###### 14. Все объекты имеют прототипы
- A: Да
- B: Нет
@@ -1001,7 +1001,7 @@ sayHi.bind(person, 21);
#### Ответ: D
-В обоих случаях мы мы передаем объект, на который будет указывать `this`. Но `.call` _выполняется сразу же_!
+В обоих случаях мы передаем объект, на который будет указывать `this`. Но `.call` _выполняется сразу же_!
`.bind` возвращает _копию_ функции, но с привязанным контекстом. Она не выполняется незамедлительно.
@@ -1182,7 +1182,7 @@ console.log(numbers);
Типы примитивов: `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, и `symbol`.
-Отличием примитива от объекта является то, что примитивы не имеют свойств или методов. Тем не менее, `'foo'.toUpperCase()` преобразуется в `'FOO'` и не вызывает `TypeError`. Это происходит потому, что при попытке получения свойства или метода у примитива (например, строки), JavaScript неявно обернет примитив объектом, используя один из классов-оберток (например, `String`), а затем сразу же уничтожет обертку после вычисления выражения. Все примитивы кроме `null` и `undefined` ведут себя таким образом.
+Отличием примитива от объекта является то, что примитивы не имеют свойств или методов. Тем не менее, `'foo'.toUpperCase()` преобразуется в `'FOO'` и не вызывает `TypeError`. Это происходит потому, что при попытке получения свойства или метода у примитива (например, строки), JavaScript неявно обернет примитив объектом, используя один из классов-оберток (например, `String`), а затем сразу же уничтожит обертку после вычисления выражения. Все примитивы кроме `null` и `undefined` ведут себя таким образом.
From 75444d84a07f9ddc09259b8965fc5b49cd25ea4b Mon Sep 17 00:00:00 2001
From: Dmitry Yevlakhov
Date: Thu, 20 Jun 2019 13:09:28 +0300
Subject: [PATCH 023/881] translated to ukrainian
---
README-bs_BS.md | 1 +
README-de_DE.md | 3 +-
README-ua_UA.md | 1296 +++++++++++++++++++++++++++++++++++++++++++++++
README-vi.md | 3 +-
README.md | 1 +
README_ru-RU.md | 11 +-
6 files changed, 1308 insertions(+), 7 deletions(-)
create mode 100644 README-ua_UA.md
diff --git a/README-bs_BS.md b/README-bs_BS.md
index 75e47080..8566ce9c 100644
--- a/README-bs_BS.md
+++ b/README-bs_BS.md
@@ -18,6 +18,7 @@ kliknite na njih da biste ih proširili. Sretno :heart:
[Zapadni balkan](./README-bs_BS.md)
[Njemački](./README-de_DE.md)
[Vijetnamski](./README-vi.md)
+[Українська мова](./README-ua_UA.md)
* * * * *
diff --git a/README-de_DE.md b/README-de_DE.md
index cefffd01..37966ada 100644
--- a/README-de_DE.md
+++ b/README-de_DE.md
@@ -9,7 +9,8 @@ Die Antworten sind unterhalb der Fragen versteckt. Du kannst einfach auf den Pfe
[English](./README.md)
[中文版本](./README-zh_CN.md)
[Русский](./README_ru-RU.md)
-[Western Balkan](./README-bs.md)
+[Western Balkan](./README-bs.md)
+[Українська мова](./README-ua_UA.md)
---
diff --git a/README-ua_UA.md b/README-ua_UA.md
new file mode 100644
index 00000000..18f2d4af
--- /dev/null
+++ b/README-ua_UA.md
@@ -0,0 +1,1296 @@
+# Список (просунутих) питань з JavaScript
+
+Я публікую щодня завдання з JavaScript в моєму [Instagram](https://www.instagram.com/theavocoder), які також додаю тут!
+
+Від базового до просунутого: перевірте, наскільки добре ви знаєте JavaScript, трохи оновлюйте свої знання або підготуйтеся до інтерв'ю! :muscle: :rocket: Щотижня я доповнюю цей репозиторій новими питаннями.
+
+Відповіді знаходяться в згорнутої секції нижче питань. Просто натисни на відповідь, щоб розгорнути. Успіхів! :heart:
+
+[中文版本](./README-zh_CN.md)
+[Русский](./README_ru-RU.md)
+[Western Balkan](./README-bs.md)
+[Deutsch](./README-de_DE.md)
+[Tiếng Việt](./README-vi.md)
+
+---
+
+###### 1. Що буде в консолі?
+
+```javascript
+function sayHi() {
+ console.log(name);
+ console.log(age);
+ var name = "Lydia";
+ let age = 21;
+}
+
+sayHi();
+```
+
+- A: `Lydia` та `undefined`
+- B: `Lydia` та `ReferenceError`
+- C: `ReferenceError` та `21`
+- D: `undefined` та `ReferenceError`
+
+Відповідь
+
+
+#### Відповідь: D
+
+Усередині функції ми спершу визначаємо змінну `name` за допомогою ключового слова `var`. Це означає, що змінна буде знайдена (область пам'яті під змінну буде виділена під час створення) зі значенням `undefined` за замовчуванням, до тих пора поки виконання коду не дійде до рядка, де визначається змінна. Ми ще не визначили значення name, коли намагаємося вивести її в консоль, тому в консолі буде `undefined`.
+
+Змінні, визначені за допомогою `let` (і `const`), також знаходяться, але на відміну від `var`, не створюються. Доступ до них неможливий до тих пір, поки не виконається рядок їх визначення (ініціалізації). Це називається "тимчасова мертва зона". Коли ми намагаємося звернутися до змінних до того моменту як вони визначені, JavaScript видає `ReferenceError`.
+
+
+
+
+---
+
+###### 2. Що буде в консолі?
+
+```javascript
+for (var i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+
+for (let i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+```
+
+- A: `0 1 2` та `0 1 2`
+- B: `0 1 2` та `3 3 3`
+- C: `3 3 3` та `0 1 2`
+
+Відповідь
+
+
+#### Відповідь: C
+
+Через черги подій в JavaScript, функція `setTimeout` викликається _після того_ як цикл буде завершено. Так як змінна `i` в першому циклі була визначена за допомогою `var`, вона буде глобальною. У циклі ми кожен раз збільшуємо значення `i` на `1`, використовуючи унарний оператор `++.` До моменту виконання функції `setTimeout` значення `i` дорівнюватиме `3`, як показано в першому прикладі.
+
+У другому циклі змінна `i` визначена за допомогою `let`. Такі змінні (а також `const`) мають блочну область видимості (блок це що завгодно між `{}`). З кожної итерацией `i` матиме нове значення, і кожне значення буде замкнуто в своїй області видимості всередині циклу.
+
+
+
+
+---
+
+###### 3. Що буде в консолі?
+
+```javascript
+const shape = {
+ radius: 10,
+ diameter() {
+ return this.radius * 2;
+ },
+ perimeter: () => 2 * Math.PI * this.radius
+};
+
+shape.diameter();
+shape.perimeter();
+```
+
+- A: `20` та `62.83185307179586`
+- B: `20` та `NaN`
+- C: `20` та `63`
+- D: `NaN` та `63`
+
+Відповідь
+
+
+#### Відповідь: B
+
+Зауваж, що `diameter` це звичайна функція, в той час як `perimeter` це функція стрілки.
+
+У стрілочних функцій значення `this` вказує на навколишню область видимості, на відміну від звичайних функцій! Це означає, що при виклику `perimeter` значення `this` у цій функції вказує не на об'єкт `shape`, а на зовнішню область видимості (наприклад, window).
+
+У цього об'єкта немає ключа `radius`, тому повертається `undefined`.
+
+
+
+
+---
+
+###### 4. Що буде в консолі?
+
+```javascript
++true;
+!"Lydia";
+```
+
+- A: `1` та `false`
+- B: `false` та `NaN`
+- C: `false` та `false`
+
+Відповідь
+
+
+#### Відповідь: A
+
+Унарний плюс призводить операнд до числа. `true` це `1`, а `false` це `0`.
+
+Строка `'Lydia'` це "справжнє" значення. Ми запитуємо "справжнє значення є помилковим"? Відповідь: `false`.
+
+
+
+
+---
+
+###### 5. Що з цього не є коректним?
+
+```javascript
+const bird = {
+ size: "small"
+};
+
+const mouse = {
+ name: "Mickey",
+ small: true
+};
+```
+
+- A: `mouse.bird.size` не є коректно
+- B: `mouse[bird.size]` не є коректно
+- C: `mouse[bird["size"]]` не є коректно
+- D: Все варіант коректні
+
+Відповідь
+
+
+#### Відповідь: A
+
+В JavaScript все ключі об'єкта є рядками (крім `Symbol`). І хоча ми не _набираємо_ їх як рядки, вони завжди перетворюються до рядків під капотом.
+
+JavaScript інтерпретує (або розпаковує) оператори. При використанні квадратних дужок JS зауважує `[` і продовжує поки не зустріне `]`. Тільки після цього він вирахує то, що знаходиться всередині дужок.
+
+`mouse[bird.size]`: Спершу визначається `bird.size`, що дорівнює `"small"`. `mouse["small"]` повертає `true`.
+
+Але із записом через точку так не відбувається. У `mouse` немає ключа `bird`. Таким чином, `mouse.bird` дорівнює `undefined`. Потім ми запитуємо ключ `size`, використовуючи точкову нотацію: `mouse.bird.size`. Так як `mouse.bird` це `undefined`, ми запитуємо `undefined.size`. Це не є дійсним, і ми отримуємо помилку типу: `Can not read property "size" of undefined`.
+
+
+
+
+---
+
+---
+
+###### 6. Що буде в консолі?
+
+```javascript
+let c = { greeting: "Hey!" };
+let d;
+
+d = c;
+c.greeting = "Hello";
+console.log(d.greeting);
+```
+
+- A: `Hello`
+- B: `Hey`
+- C: `undefined`
+- D: `ReferenceError`
+- E: `TypeError`
+
+Відповідь
+
+
+#### Відповідь: A
+
+В JavaScript всі об'єкти є _посилальними_ типами даних.
+
+Спершу змінна `c` вказує на об'єкт. Потім ми вказуємо змінної `d` посилатися на той самий об'єкт, що і `c`.
+
+
+
+Коли ти змінюєш один об'єкт, то змінюються значення всіх посилань, що вказують на цей об'єкт.
+
+
+
+
+---
+
+###### 7. Що буде в консолі?
+
+```javascript
+let a = 3;
+let b = new Number(3);
+let c = 3;
+
+console.log(a == b);
+console.log(a === b);
+console.log(b === c);
+```
+
+- A: `true` `false` `true`
+- B: `false` `false` `true`
+- C: `true` `false` `false`
+- D: `false` `true` `true`
+
+Відповідь
+
+
+#### Відповідь: C
+
+`new Number()` це вбудований конструктор функції. І хоча він виглядає як число, це не справжнє число: у нього є ряд додаткових фіч і це об'єкт.
+
+Оператор `==` призводить типи даних до якогось одного і перевіряє рівність _значень_. Обидва значення рівні `3`, тому повертається `true`.
+
+При використанні оператора `===` значення і тип повинні бути однаковими. Але в нашому випадку це не так: `new Number()` це не число, це **об'єкт**. Тому обидва повертають `false`.
+
+
+
+
+---
+
+###### 8. Яким буде результат?
+
+```javascript
+class Chameleon {
+ static colorChange(newColor) {
+ this.newColor = newColor;
+ return this.newColor;
+ }
+
+ constructor({ newColor = "green" } = {}) {
+ this.newColor = newColor;
+ }
+}
+
+const freddie = new Chameleon({ newColor: "purple" });
+freddie.colorChange("orange");
+```
+
+- A: `orange`
+- B: `purple`
+- C: `green`
+- D: `TypeError`
+
+Відповідь
+
+
+#### Відповідь: D
+
+Функція `colorChange` є статичною. Статичні методи не мають доступу до екземплярів класу. Так як `freddie` це екземпляр, то статичний метод там не доступний. Тому результатом є помилка `TypeError`.
+
+
+
+
+---
+
+###### 9. Що буде в консолі?
+
+```javascript
+let greeting;
+greetign = {}; // Typo!
+console.log(greetign);
+```
+
+- A: `{}`
+- B: `ReferenceError: greetign is not defined`
+- C: `undefined`
+
+Відповідь
+
+
+#### Відповідь: A
+
+В консолі виведеться об'єкт, тому що ми тільки що створили порожній об'єкт в глобальному об'єкті! Коли ми замість `greeting` написали `greetign`, інтерпретатор JS насправді виконав `global.greetign = {}` (або `window.greetign = {}` в браузері).
+
+Потрібно використовувати `"use strict"`, щоб уникнути такої поведінки. Ця запис допоможе бути впевненим в тому, що змінна була визначена перед тим як їй присвоїли значення.
+
+
+
+
+---
+
+###### 10. Що станеться?
+
+```javascript
+function bark() {
+ console.log("Woof!");
+}
+
+bark.animal = "dog";
+```
+
+- A: Нічого, все ок.
+- B: `SyntaxError`. Не можна додавати властивості функцій таким способом.
+- C: `undefined`
+- D: `ReferenceError`
+
+Відповідь
+
+
+#### Відповідь: A
+
+В JavaScript це можливо, тому що функції це об'єкти! (Все є об'єктами крім примітивів).
+
+Функція - це спеціальний тип об'єкта, який можна викликати. Крім того, функція - це об'єкт з властивостями. Властивість такого об'єкта не можна викликати, так як воно не є функцією.
+
+
+
+
+---
+
+###### 11. Що буде в консолі?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const member = new Person("Lydia", "Hallie");
+Person.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+
+console.log(member.getFullName());
+```
+
+- A: `TypeError`
+- B: `SyntaxError`
+- C: `Lydia Hallie`
+- D: `undefined` `undefined`
+
+Відповідь
+
+
+#### Відповідь: A
+
+Не можна додавати властивості конструктору, як звичайному об'єкту. Якщо потрібно додати фичу всіх об'єктах, то необхідно використовувати прототипи. В даному випадку,
+
+```js
+Person.prototype.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+```
+
+зробить метод `member.getFullName()` чинним. У чому тут перевага? Припустимо, що ми додали цей метод до конструктора. Можливо, не кожному екземпляру `Person` потрібен цей метод. Це призведе до великих втрат пам'яті, тому що всі екземпляри будуть мати цю властивість. Навпаки, якщо ми додамо цей метод тільки до прототипу, у нас буде тільки одне місце в пам'яті, до якого зможуть звертатися всі екземпляри!
+
+
+
+
+---
+
+###### 12. Що буде в консолі?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const lydia = new Person("Lydia", "Hallie");
+const sarah = Person("Sarah", "Smith");
+
+console.log(lydia);
+console.log(sarah);
+```
+
+- A: `Person {firstName: "Lydia", lastName: "Hallie"}` та `undefined`
+- B: `Person {firstName: "Lydia", lastName: "Hallie"}` та `Person {firstName: "Sarah", lastName: "Smith"}`
+- C: `Person {firstName: "Lydia", lastName: "Hallie"}` та `{}`
+- D:`Person {firstName: "Lydia", lastName: "Hallie"}` та `ReferenceError`
+
+Відповідь
+
+
+#### Відповідь: A
+
+Для `sarah` ми не використали ключове слово `new`. Використання `new` призводить до створення нового об'єкта. Але без `new` він вказує на **глобальний об'єкт**!
+
+Ми вказали, що `this.firstName` дорівнює `"Sarah"` і `this.lastName` дорівнює `"Smith"`. Насправді ми визначили `global.firstName = 'Sarah'` і `global.lastName = 'Smith'`. `sarah` залишилася `undefined`.
+
+
+
+
+---
+
+###### 13. Назвіть три фази поширення подій
+
+- A: Мета (Target) > Захоплення (Capturing) > Всплиття (Bubbling)
+- B: Всплиття (Bubbling) > Мета (Target) > Захоплення (Capturing)
+- C: Мета (Target) > Всплиття (Bubbling) > Захоплення (Capturing)
+- D: Захоплення (Capturing) > Мета (Target) > Всплиття (Bubbling)
+
+Відповідь
+
+
+#### Відповідь: D
+
+Під час фази **захоплення** подія поширюється з елементів батьків до елемента мети. Після досягнення **мети** починається фаза **спливання**.
+
+
+
+
+
+
+---
+
+###### 14. Все объекты имеют прототипы?
+
+- A: Так
+- B: Ні
+
+Відповідь
+
+
+#### Відповідь: B
+
+Всі об'єкти мають прототипи, крім **базового об'єкта**. Базовий об'єкт має доступ до деяких методів і властивостей, таких як `.toString`. Саме тому ми можемо використовувати вбудовані методи JavaScript! Всі ці методи доступні в прототипі. Якщо JavaScript не може знайти метод безпосередньо у об'єкту, він продовжує пошук по ланцюжку прототипів поки не знайде.
+
+
+
+
+---
+
+###### 15. Результат коду?
+
+```javascript
+function sum(a, b) {
+ return a + b;
+}
+
+sum(1, "2");
+```
+
+- A: `NaN`
+- B: `TypeError`
+- C: `"12"`
+- D: `3`
+
+Відповідь
+
+
+#### Відповідь: C
+
+JavaScript це **динамічно тіпізірованна мова**: ми не визначаємо тип змінних. Змінні можуть автоматично бути перетворені з одного типу в інший без нашої участі, що називається _неявним приведенням типів_. **Приведення** це перетворення з одного типу в інший.
+
+У цьому прикладі, JavaScript конвертувати число `1` в рядок, щоб операція усередині функції мала сенс і повернула значення. Під час складання числа (`1`) і рядки (`'2'`) число перетворюється до рядка. Ми можемо конкатеніровать рядки ось так: `"Hello" + "World"`. Таким чином, "`1"` + `"2"` повертає "`12"`.
+
+
+
+
+---
+
+###### 16. Що буде в консолі?
+
+```javascript
+let number = 0;
+console.log(number++);
+console.log(++number);
+console.log(number);
+```
+
+- A: `1` `1` `2`
+- B: `1` `2` `2`
+- C: `0` `2` `2`
+- D: `0` `1` `2`
+
+Відповідь
+
+
+#### Відповідь: C
+
+**Постфіксний** унарний оператор `++`:
+
+1. Повертає значення (`0`)
+2. Інкрементує значення (тепер число дорівнює `1`)
+
+**Префіксний** унарний оператор `++`:
+
+1. Інкрементує значення (тепер число дорівнює `1`)
+2. Повертає значення (`0`)
+
+Результат: `0 2 2`.
+
+
+
+
+---
+
+###### 17. Що буде в консолі?
+
+```javascript
+function getPersonInfo(one, two, three) {
+ console.log(one);
+ console.log(two);
+ console.log(three);
+}
+
+const person = "Lydia";
+const age = 21;
+
+getPersonInfo`${person} is ${age} years old`;
+```
+
+- A: `"Lydia"` `21` `["", " is ", " years old"]`
+- B: `["", " is ", " years old"]` `"Lydia"` `21`
+- C: `"Lydia"` `["", " is ", " years old"]` `21`
+
+Відповідь
+
+
+#### Відповідь: B
+
+При використанні тегованих шаблонних литералов першим аргументом завжди буде масив строкових значень. Залишилися аргументами будуть значення переданих виразів!
+
+
+
+
+---
+
+###### 18. Що буде в консолі?
+
+```javascript
+function checkAge(data) {
+ if (data === { age: 18 }) {
+ console.log("You are an adult!");
+ } else if (data == { age: 18 }) {
+ console.log("You are still an adult.");
+ } else {
+ console.log(`Hmm.. You don't have an age I guess`);
+ }
+}
+
+checkAge({ age: 18 });
+```
+
+- A: `You are an adult!`
+- B: `You are still an adult.`
+- C: `Hmm.. You don't have an age I guess`
+
+Відповідь
+
+
+#### Відповідь: C
+
+В операціях порівняння примітиви порівнюються за їх _значенням_, а об'єкти по _посиланнях_. JavaScript перевіряє, щоб об'єкти вказували на одну і ту ж область пам'яті.
+
+Порівнянні об'єкти в нашому прикладі не такі: об'єкт, переданий як параметр, вказує на іншу область пам'яті, ніж об'єкти, що використовуються в порівняннях.
+
+Тому `{age: 18} === {age: 18}` і `{age: 18} == {age: 18}` повертають `false`.
+
+
+
+
+---
+
+###### 19. Що буде в консолі?
+
+```javascript
+function getAge(...args) {
+ console.log(typeof args);
+}
+
+getAge(21);
+```
+
+- A: `"number"`
+- B: `"array"`
+- C: `"object"`
+- D: `"NaN"`
+
+Відповідь
+
+
+#### Відповідь: C
+
+Оператор поширення (`... args`) повертає масив з аргументами. Масив це об'єкт, тому `typeof args` повертає `"object"`.
+
+
+
+
+---
+
+###### 20. Що буде в консолі?
+
+```javascript
+function getAge() {
+ "use strict";
+ age = 21;
+ console.log(age);
+}
+
+getAge();
+```
+
+- A: `21`
+- B: `undefined`
+- C: `ReferenceError`
+- D: `TypeError`
+
+Відповідь
+
+
+#### Відповідь: C
+
+Використовуючи `"use strict"`, можна бути впевненим, що ми помилково не оголосимо глобальні змінні. Ми раніше ніде не оголошували змінну `age`, тому з використанням `"use strict"` виникне ReferenceError. Без використання `"use strict"` помилки не виникне, а змінна `age` додасться в глобальний об'єкт.
+
+
+
+
+---
+
+###### 21. Чому дорівнюватиме sum?
+
+```javascript
+const sum = eval("10*10+5");
+```
+
+- A: `105`
+- B: `"105"`
+- C: `TypeError`
+- D: `"10*10+5"`
+
+Відповідь
+
+
+#### Відповідь: A
+
+`eval` виконує код, переданий у вигляді рядка. Якщо цей вислів (як в даному випадку), то обчислюється вираз. Вираз `10 * 10 + 5` поверне число `105`.
+
+
+
+
+---
+
+###### 22. Як довго буде доступний cool_secret?
+
+```javascript
+sessionStorage.setItem("cool_secret", 123);
+```
+
+- A: Завжди, дані не загубляться.
+- B: Поки користувач не закриває вкладку.
+- C: Поки користувач не закриє браузер, а не тільки вкладку.
+- D: Поки користувач не вимикає комп'ютер.
+
+Відповідь
+
+
+#### Відповідь: B
+
+Дані, збережені в `sessionStorage` очищаються після закриття _вкладки_.
+
+При використанні `localStorage` дані зберігаються назавжди. Очистити їх можна, наприклад, використовуючи `localStorage.clear()`.
+
+
+
+
+---
+
+###### 23. Що буде в консолі?
+
+```javascript
+var num = 8;
+var num = 10;
+
+console.log(num);
+```
+
+- A: `8`
+- B: `10`
+- C: `SyntaxError`
+- D: `ReferenceError`
+
+Відповідь
+
+
+#### Відповідь: B
+
+За допомогою ключового слова `var`, можна визначати скільки завгодно змінних з одним і тим же ім'ям. Змінна зберігатиме останнім присвоєне значення.
+
+Ви не можете зробити це з `let` або` const`, оскільки вони блочні.
+
+
+
+
+---
+
+###### 24. Що буде в консолі?
+
+```javascript
+const obj = { 1: "a", 2: "b", 3: "c" };
+const set = new Set([1, 2, 3, 4, 5]);
+
+obj.hasOwnProperty("1");
+obj.hasOwnProperty(1);
+set.has("1");
+set.has(1);
+```
+
+- A: `false` `true` `false` `true`
+- B: `false` `true` `true` `true`
+- C: `true` `true` `false` `true`
+- D: `true` `true` `true` `true`
+
+Відповідь
+
+
+#### Відповідь: C
+
+Всі ключі об'єктів (крім `Symbols`) є рядками, навіть якщо задано не в вигляді рядків. Тому `obj.hasOwnProperty('1')` так само повертає `true`.
+
+Але це не працює для `set`. Значення `"1"` немає в `set`: `set.has ('1')`, тому повертається `false`. Але `set.has(1)` поверне `true`.
+
+
+
+
+---
+
+###### 25. Що буде в консолі?
+
+```javascript
+const obj = { a: "one", b: "two", a: "three" };
+console.log(obj);
+```
+
+- A: `{ a: "one", b: "two" }`
+- B: `{ b: "two", a: "three" }`
+- C: `{ a: "three", b: "two" }`
+- D: `SyntaxError`
+
+Відповідь
+
+
+#### Відповідь: C
+
+Якщо є два ключі з однаковим ім'ям, то ключ буде перезаписан. Його позиція збережеться, але значенням буде встановлено останнім.
+
+
+
+
+---
+
+###### 26. Глобальний контекст виконання створює дві речі: глобальний об'єкт і this
+
+- A: Так
+- B: Ні
+- C: В залежності від ситуації
+
+Відповідь
+
+
+#### Відповідь: A
+
+Базовий контекст виконання це глобальний контекст виконання: це те, що є де завгодно в твоєму коді.
+
+
+
+
+---
+
+###### 27. Що буде в консолі?
+
+```javascript
+for (let i = 1; i < 5; i++) {
+ if (i === 3) continue;
+ console.log(i);
+}
+```
+
+- A: `1` `2`
+- B: `1` `2` `3`
+- C: `1` `2` `4`
+- D: `1` `3` `4`
+
+Відповідь
+
+
+#### Відповідь: C
+
+Оператор `continue` пропускає ітерацію, якщо умова повертає `true`.
+
+
+
+
+---
+
+###### 28. Яким буде результат?
+
+```javascript
+String.prototype.giveLydiaPizza = () => {
+ return "Just give Lydia pizza already!";
+};
+
+const name = "Lydia";
+
+name.giveLydiaPizza();
+```
+
+- A: `"Just give Lydia pizza already!"`
+- B: `TypeError: not a function`
+- C: `SyntaxError`
+- D: `undefined`
+
+Відповідь
+
+
+#### Відповідь: A
+
+`String` це вбудований конструктор, до якого можна додавати властивості. Я додала метод до його прототипу. Рядки-примітиви автоматично конвертуються до рядків-об'єктів. Тому всі рядки (строкові об'єкти) мають доступ до цього методу!
+
+
+
+
+---
+
+###### 29. Що буде в консолі?
+
+```javascript
+const a = {};
+const b = { key: "b" };
+const c = { key: "c" };
+
+a[b] = 123;
+a[c] = 456;
+
+console.log(a[b]);
+```
+
+- A: `123`
+- B: `456`
+- C: `undefined`
+- D: `ReferenceError`
+
+Відповідь
+
+
+#### Відповідь: B
+
+Ключі об'єкта автоматично конвертуються в рядки. Ми збираємося додати об'єкт в якості ключа до об'єкта `a` зі значенням `123`.
+
+Проте, коли ми наводимо об'єкт до рядка, він стає `"[object Object]"`. Таким чином, ми говоримо, що `a["Object object"] = 123`. Потім ми робимо те ж саме. `c` це інший об'єкт, який ми неявно наводимо до рядка. Тому `a["Object object"] = 456`.
+
+Потім, коли ми виводимо `a[b]`, ми маємо на увазі `a["Object object"]`. Ми тільки що встановили туди значення `456`, тому в результаті отримуємо `456`.
+
+
+
+
+---
+
+###### 30. Яким буде результат?
+
+```javascript
+const foo = () => console.log("First");
+const bar = () => setTimeout(() => console.log("Second"));
+const baz = () => console.log("Third");
+
+bar();
+foo();
+baz();
+```
+
+- A: `First` `Second` `Third`
+- B: `First` `Third` `Second`
+- C: `Second` `First` `Third`
+- D: `Second` `Third` `First`
+
+Відповідь
+
+
+#### Відповідь: B
+
+Ми викликаємо функцію `setTimeout` першої. Тим не менш, вона виводиться в консоль останньої
+
+Це відбувається через те, що в браузерах у нас є не тільки рантайм движок, але і `WebAPI`. `WebAPI` надає нам функцію `setTimeout` і багато інших можливостей. Наприклад, DOM.
+
+Після того як _коллбек_ відправлений в `WebAPI`, функція `setTimeout` (але не коллбек!) виймається з стека.
+
+
+
+Тепер викликається `foo`, і `"First"` виводиться в консоль.
+
+
+
+`foo` дістається з стека, і викликається `baz`. `"Third"` виводиться в консоль.
+
+
+
+`WebAPI` не може додавати вміст в стек коли захоче. Замість цього він відправляє коллбек-функцію в так звану _чергу_.
+
+
+
+Тут на сцену виходить цикл подій (event loop). **Event loop** перевіряє стек і черга завдань. Якщо стек порожній, то він бере перший елемент з черги і відправляє його в стек.
+
+
+
+Викликається `bar`, в консоль виводиться `"Second"` і ця функція дістається з стека.
+
+
+
+
+---
+
+###### 31. Що буде в `event.target` після кліка на кнопку?
+
+```html
+
+```
+
+- A: Зовнішній `div`
+- B: Внутрішній `div`
+- C: `button`
+- D: Масив з усіма вкладеними елементами
+
+Відповідь
+
+
+#### Відповідь: C
+
+Метою події є **найглибший** вкладений елемент. Зупинити поширення подій можна за допомогою `event.stopPropagation`
+
+
+
+
+---
+
+###### 32. Що буде в консолі після кліка по параграфу?
+
+```html
+
+```
+
+- A: `p` `div`
+- B: `div` `p`
+- C: `p`
+- D: `div`
+
+Відповідь
+
+
+#### Відповідь: A
+
+Після кліка по `p` буде виведено `p` та `div`. У циклі життя події є три фази: **захоплення**, **мета** і **спливання**. За замовчуванням обробники подій виконуються на фазі спливання (якщо не встановлено параметр `useCapture` в `true`). Спливання йде з найглибшого елемента вгору.
+
+
+
+
+---
+
+###### 33. Що буде в консолі?
+
+```javascript
+const person = { name: "Lydia" };
+
+function sayHi(age) {
+ console.log(`${this.name} is ${age}`);
+}
+
+sayHi.call(person, 21);
+sayHi.bind(person, 21);
+```
+
+- A: `undefined is 21` `Lydia is 21`
+- B: `function` `function`
+- C: `Lydia is 21` `Lydia is 21`
+- D: `Lydia is 21` `function`
+
+Відповідь
+
+
+#### Відповідь: D
+
+В обох випадках ми передаємо об'єкт, на який буде вказувати `this`. Але `.call` виконується _відразу ж_!
+
+`.bind` повертає _копію_ функції, але з прив'язаним контекстом. Вона не виконується негайно.
+
+
+
+
+---
+
+###### 34. Яким буде результат?
+
+```javascript
+function sayHi() {
+ return (() => 0)();
+}
+
+typeof sayHi();
+```
+
+- A: `"object"`
+- B: `"number"`
+- C: `"function"`
+- D: `"undefined"`
+
+Відповідь
+
+
+#### Відповідь: B
+
+Функція `sayHi` повертає значення, що повертається з _негайно викликаного функціонального вираза_ (IIFE). Результатом є `0` типу `"number"`.
+
+Для інформації: в JS 7 вбудованих типів: `null`, `undefined`, `boolean`, `number`, `string`, `object`, та `symbol`. `"Function"` не є окремим типом, тому що функції є об'єктами типу `"object"`.
+
+
+
+
+---
+
+###### 35. Які з цих значень є "помилковими"?
+
+```javascript
+0;
+new Number(0);
+("");
+(" ");
+new Boolean(false);
+undefined;
+```
+
+- A: `0`, `''`, `undefined`
+- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
+- C: `0`, `''`, `new Boolean(false)`, `undefined`
+- D: Всі значення.
+
+Відповідь
+
+
+#### Відповідь: A
+
+Є тільки шість "помилкових" значень:
+
+- `undefined`
+- `null`
+- `NaN`
+- `0`
+- `''` (порожній рядок)
+- `false`
+
+Конструктори функцій, такі як new `Number` та `new Boolean` є "істинними".
+
+
+
+
+---
+
+###### 36. Що буде в консолі?
+
+```javascript
+console.log(typeof typeof 1);
+```
+
+- A: `"number"`
+- B: `"string"`
+- C: `"object"`
+- D: `"undefined"`
+
+Відповідь
+
+
+#### Відповідь: B
+
+`typeof 1` повертає `"number"`.
+`typeof "number"` повертає `"string"`
+
+
+
+
+---
+
+###### 37. Що буде в консолі?
+
+```javascript
+const numbers = [1, 2, 3];
+numbers[10] = 11;
+console.log(numbers);
+```
+
+- A: `[1, 2, 3, 7 x null, 11]`
+- B: `[1, 2, 3, 11]`
+- C: `[1, 2, 3, 7 x empty, 11]`
+- D: `SyntaxError`
+
+Відповідь
+
+
+#### Відповідь: C
+
+Коли в масив додається значення, яке виходить за межі довжини масиву, JavaScript створює так звані "порожні клітинки". Насправді вони мають значення `undefined`, але в консолі виводяться так:
+
+`[1, 2, 3, 7 x empty, 11]`
+
+в залежності від місця використання (може відрізнятися для браузерів, Node, і т.д.).
+
+
+
+
+---
+
+###### 38. Що буде в консолі?
+
+```javascript
+(() => {
+ let x, y;
+ try {
+ throw new Error();
+ } catch (x) {
+ (x = 1), (y = 2);
+ console.log(x);
+ }
+ console.log(x);
+ console.log(y);
+})();
+```
+
+- A: `1` `undefined` `2`
+- B: `undefined` `undefined` `undefined`
+- C: `1` `1` `2`
+- D: `1` `undefined` `undefined`
+
+Відповідь
+
+
+#### Відповідь: A
+
+Блок `catch` отримує аргумент `x`. Це не той же `x`, який визначено в якості змінної перед рядком `try`.
+
+Потім ми присвоюємо цього аргументу значення `1` та встановлюємо значення для змінної `y`. Потім виводимо в консоль значення аргументу `x`, що дорівнює `1`.
+
+За межами блоку `catch` змінна `x` все ще `undefined`, а `y` дорівнює `2`. Коли ми викликаємо` console.log(x)` за межами блоку `catch`, цей виклик повертає `undefined`, а `y` повертає `2`.
+
+
+
+
+---
+
+###### 39. Все в JavaScript це...
+
+- A: примітив або об'єкт
+- B: функція або об'єкт
+- C: питання з підступом! тільки об'єкти
+- D: число або об'єкт
+
+Відповідь
+
+
+#### Відповідь: A
+
+В JavaScript є тільки примітиви і об'єкти.
+
+Типи примітивів: `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, та `symbol`.
+
+Відмінністю примітиву від об'єкта є те, що примітиви не мають властивостей або методів. Проте, `'foo'.toUpperCase()` перетворюється в `'FOO'` та не викликає `TypeError`. Це відбувається тому, що при спробі отримання властивості або методу у примітиву (наприклад, рядки), JavaScript неявно оберне примітив об'єктом, використовуючи один з класів-обгорток (наприклад, `String`), а потім відразу ж знищить обгортку після обчислення виразу. Всі примітиви крім `null` та `undefined` поводяться таким чином.
+
+
+
+
+---
+
+###### 40. Що буде в консолі?
+
+```javascript
+[[0, 1], [2, 3]].reduce(
+ (acc, cur) => {
+ return acc.concat(cur);
+ },
+ [1, 2]
+);
+```
+
+- A: `[0, 1, 2, 3, 1, 2]`
+- B: `[6, 1, 2]`
+- C: `[1, 2, 0, 1, 2, 3]`
+- D: `[1, 2, 6]`
+
+Відповідь
+
+
+#### Відповідь: C
+
+`[1, 2]` - початкове значення, з яким инициализируется змінна `acc`. Після першого проходу `acc` дорівнюватиме `[1,2]`, а `cur` буде `[0,1]`. Після конкатенації результат буде `[1, 2, 0, 1]`.
+
+Потім `acc` дорівнює `[1, 2, 0, 1]`, а cur `[2, 3]`. Після злиття отримаємо `[1, 2, 0, 1, 2, 3]`.
+
+
+
+
+---
+
+###### 41. Що буде в консолі?
+
+```javascript
+!!null;
+!!"";
+!!1;
+```
+
+- A: `false` `true` `false`
+- B: `false` `false` `true`
+- C: `false` `true` `true`
+- D: `true` `true` `false`
+
+Відповідь
+
+
+#### Відповідь: B
+
+`null` "НЕправдивий". `!null` повертає `true`. `!true` повертає `false`.
+
+`""` "НЕправдивий". `!""` повертає `true`. `!true` повертає `false`.
+
+`1` "правдивий". `!1` повертає `false`. `!false` повертає `true`.
+
+
+
+
+---
+
+###### 42. Що повертає метод `setInterval`?
+
+```javascript
+setInterval(() => console.log("Hi"), 1000);
+```
+
+- A: унікальний id
+- B: вказану кількість мілісекунд
+- C: передану функцію
+- D: `undefined`
+
+Відповідь
+
+
+#### Відповідь: A
+
+Це метод повертає унікальний id. Цей id може бути використаний для очищення інтервалу за допомогою функції `clearInterval()`.
+
+
+
+
+---
+
+###### 43. What does this return?
+
+```javascript
+[..."Lydia"];
+```
+
+- A: `["L", "y", "d", "i", "a"]`
+- B: `["Lydia"]`
+- C: `[[], "Lydia"]`
+- D: `[["L", "y", "d", "i", "a"]]`
+
+Відповідь
+
+
+#### Відповідь: A
+
+Рядок є ітеріруемой сутністю. Оператор поширення перетворює кожен символ в окремий елемент.
+
+
+
diff --git a/README-vi.md b/README-vi.md
index b9b7c3be..69bb004d 100644
--- a/README-vi.md
+++ b/README-vi.md
@@ -6,7 +6,8 @@ Các câu hỏi sẽ từ cơ bản đến nâng cao: kiểm tra trình độ Ja
Các đáp án được đặt dưới mỗi câu hỏi, hãy click để tham khảo chúng. Chúc may mắn :heart:
-[English Version](./README.md)
+[English Version](./README.md)
+[Українська мова](./README-ua_UA.md)
---
diff --git a/README.md b/README.md
index 916fa133..8d31ae8d 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ The answers are in the collapsed sections below the questions, simply click on t
[Western Balkan](./README-bs_BS.md)
[Deutsch](./README-de_DE.md)
[Tiếng Việt](./README-vi.md)
+[Українська мова](./README-ua_UA.md)
---
diff --git a/README_ru-RU.md b/README_ru-RU.md
index b8e918df..34ab16a5 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -6,11 +6,12 @@
Ответы находятся в свернутой секции ниже вопросов. Просто нажми на "Ответ", чтобы развернуть. Удачи! :heart:
-[中文版本](./README-zh_CN.md)
-[Русский](./README_ru-RU.md)
-[Western Balkan](./README-bs.md)
-[Deutsch](./README-de_DE.md)
-[Tiếng Việt](./README-vi.md)
+[中文版本](./README-zh_CN.md)
+[Русский](./README_ru-RU.md)
+[Western Balkan](./README-bs.md)
+[Deutsch](./README-de_DE.md)
+[Tiếng Việt](./README-vi.md)
+[Українська мова](./README-ua_UA.md)
---
From 2551a7da286424e983bec43eaabf467554c62444 Mon Sep 17 00:00:00 2001
From: Antoine Nozeret
Date: Thu, 20 Jun 2019 12:10:21 +0200
Subject: [PATCH 024/881] feat(question-8): Add console.log to make the answer
less obvious
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 916fa133..68533ba3 100644
--- a/README.md
+++ b/README.md
@@ -259,7 +259,7 @@ class Chameleon {
}
const freddie = new Chameleon({ newColor: "purple" });
-freddie.colorChange("orange");
+console.log(freddie.colorChange("orange"));
```
- A: `orange`
From 1ca20d0c1a4a67fae2bf0e507dffe5850cdba4e5 Mon Sep 17 00:00:00 2001
From: 0xflotus <0xflotus@gmail.com>
Date: Thu, 20 Jun 2019 15:16:29 +0200
Subject: [PATCH 025/881] Update README-de_DE.md
---
README-de_DE.md | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/README-de_DE.md b/README-de_DE.md
index cefffd01..39f25be5 100644
--- a/README-de_DE.md
+++ b/README-de_DE.md
@@ -36,9 +36,9 @@ sayHi()
#### Antwort: D
-Innerhalb der Funktion wird zuerst der `name` mit dem `var` Keyword gesetzt. Das bedeuted, dass die Variable mit dem Standardwert `undefined` gehoisted wird (Speicherplatz wird während der Erstellung bereitgestellt), bis zu der Zeile, wo wir die Variable definieren. Da wir die Variable auf der Zeile, wo wir den `name` loggen noch nicht gesetzt haben, ist dieser noch `undefined`.
+Innerhalb der Funktion wird zuerst der `name` mit dem `var` Keyword gesetzt. Das bedeutet, dass die Variable mit dem Standardwert `undefined` gehoisted wird (Speicherplatz wird während der Erstellung bereitgestellt), bis zu der Zeile, wo wir die Variable definieren. Da wir die Variable auf der Zeile, wo wir den `name` loggen noch nicht gesetzt haben, ist dieser noch `undefined`.
-Variablen mit dem `let` (oder `const`) Keyword werden ebenfalls gehoisted, aber im Gegensatz zu `var` werden diese nicht initialisiert. Auf sie können wir daher nicht zugreifen, bevor sie definiert worden sind. JavaScript wirft einen `ReferenceError` aus.
+Variablen mit dem `let` (oder `const`) Keyword werden ebenfalls gehoisted, aber im Gegensatz zu `var` werden diese nicht initialisiert. Auf sie können wir daher nicht zugreifen, bevor sie definiert worden sind. JavaScript wirft einen `ReferenceError`.
@@ -66,7 +66,7 @@ for (let i = 0; i < 3; i++) {
#### Antwort: C
-Aufgrund der Event Queue in JavaScript, wird die callback function in `setTimeout` _nach_ der Schleife ausgeführt. Da die Variable `i` in der ersten Schleife mit dem `var` Keyword definiert wurde, ist dieser Wert global verfügbar. Während der Schleife wird der Wert von `i` jedesmal mithilfe des `++` Operators um `1` erhöht. Zu dem Zeitpunkt, wenn die callback function in `setTimeout` aufgerufen wird, ist `i` gleich `3` im ersten Beispiel.
+Aufgrund der Event Queue in JavaScript, wird die Callback Funktion in `setTimeout` _nach_ der Schleife ausgeführt. Da die Variable `i` in der ersten Schleife mit dem `var` Keyword definiert wurde, ist dieser Wert global verfügbar. Während der Schleife wird der Wert von `i` jedesmal mithilfe des `++` Operators um `1` erhöht. Zu dem Zeitpunkt, wenn die Callback Funktion in `setTimeout` aufgerufen wird, ist `i` gleich `3` im ersten Beispiel.
In der zweiten Schleife wurde die Variable `i` mit dem `let` Keyword definiert: Variablen, die mit `let` (oder `const`) deklariert werden sind block-scoped (Ein Block ist alles zwischen `{ }`). Während jedem Durchlauf bekommt `i` einen neuen Wert zugewiesen, der jeweils innerhalb des Scopes der Schleife liegt.
@@ -233,7 +233,7 @@ console.log(b === c)
`new Number()` ist ein eingebauter Function Constructor. Auch wenn der Wert wie eine Nummer aussieht, ist es in Wirklichkeit keine Nummer, sondern beinhaltet eine Menge zusätzlicher Werte und ist daher ein Object.
-Wenn wir `==` nutzen wird nur geprüft, ob der _Wert_ gleich ist. Da beide den Wert `3` haben wird `true` zurückgegeben.
+Wenn wir `==` nutzen wird nur geprüft, ob der _Wert_ gleich ist. Da beide den Wert `3` haben, wird `true` zurückgegeben.
Wenn wir aber `===` nutzen müssen sowohl der Wert _als auch_ der Typ übereinstimmen. Das ist `false`, da `new Number()` keine Nummer, sondern ein **Object** ist.
@@ -366,7 +366,7 @@ Person.prototype.getFullName = function() {
}
```
-So hätte `member.getFullName()` funktioniert. Warum ist das von Vorteil? Sagen wir, wir hätten diese Methode dem Constructor selbst zugewiesen, aber vielleicht benötigt nicht jede Instanz von `Person` diese Methode. So hätte das eine Menge Arbeitsspeicher verschwendet, weil jede Instanz die Property zugewiesen bekommt, auch wenn sie diese garnicht benötigt.
+So hätte `member.getFullName()` funktioniert. Warum ist das von Vorteil? Sagen wir, wir hätten diese Methode dem Constructor selbst zugewiesen, aber vielleicht benötigt nicht jede Instanz von `Person` diese Methode. So hätte das eine Menge Arbeitsspeicher verschwendet, weil jede Instanz die Property zugewiesen bekommt, auch wenn sie diese gar nicht benötigt.
Stattdessen haben wir sie nur dem Prototype zugewiesen, sodass sie nur an einer Stelle im Arbeitsspeicher hinterlegt ist, aber dennoch haben alle Instanzen Zugriff darauf.
@@ -389,10 +389,10 @@ console.log(lydia)
console.log(sarah)
```
-- A: `Person {firstName: "Lydia", lastName: "Hallie"}` and `undefined`
-- B: `Person {firstName: "Lydia", lastName: "Hallie"}` and `Person {firstName: "Sarah", lastName: "Smith"}`
-- C: `Person {firstName: "Lydia", lastName: "Hallie"}` and `{}`
-- D:`Person {firstName: "Lydia", lastName: "Hallie"}` and `ReferenceError`
+- A: `Person {firstName: "Lydia", lastName: "Hallie"}` und `undefined`
+- B: `Person {firstName: "Lydia", lastName: "Hallie"}` und `Person {firstName: "Sarah", lastName: "Smith"}`
+- C: `Person {firstName: "Lydia", lastName: "Hallie"}` und `{}`
+- D:`Person {firstName: "Lydia", lastName: "Hallie"}` und `ReferenceError`
Antwort
@@ -401,7 +401,7 @@ console.log(sarah)
Für `sarah` haben wir nicht das `new` Keyword verwendet. Wenn wir `new` verwenden, bezieht sich das auf das neue, leere Object, welches wir erstellen. Wenn wir allerdings das `new` Keyword nicht verwenden, bezieht es sich auf das **globale Objekt**.
-Wir haben `this.firstName` den Wert `"Sarah"` zugewiesen und `this.lastName` den Wert `"Smith"`. Was wir damit eigentlich zugewiesen haben ist `global.firstName = 'Sarah'` und `global.lastName = 'Smith'`. `sarah` selbst ist daher `undefined`.
+Wir haben `this.firstName` den Wert `"Sarah"` zugewiesen und `this.lastName` den Wert `"Smith"`. Was wir damit eigentlich zugewiesen haben, ist `global.firstName = 'Sarah'` und `global.lastName = 'Smith'`. `sarah` selbst ist daher `undefined`.
@@ -420,7 +420,7 @@ Wir haben `this.firstName` den Wert `"Sarah"` zugewiesen und `this.lastName` den
#### Antwort: D
-Während der **capturing** Phase geht das Event durch die Elternelemente bis hin zum Zielelement. Wenn dann das Ziel (**target**) erreicht ist beginnt die **bubbling** Phase.
+Während der **capturing** Phase geht das Event durch die Elternelemente bis hin zum Zielelement. Wenn dann das Ziel (**target**) erreicht ist, beginnt die **bubbling** Phase.
@@ -468,7 +468,7 @@ sum(1, "2")
JavaScript ist eine **Sprache mit dynamischen Typen**, was bedeutet, dass wir Variablen keine spezifischen Typen zuweisen. Werte können automatisch in einen anderen Typ umgewandelt werden, was _implicit type coercion_ genannt wird. **Coercion** (dt. "Zwang") ist die Umwandlung von einem Typ zu einem anderen.
-In diesem Beispiel wandelt JavaScript die Nummer `1` in einem String um, sodass die Funktion Sinn ergibt und einen Wert zurück werfen kann. Während der Addition eines numerischen Types (`1`) mit einem String (`'2'`) wird die Nummer wie ein String behandelt. Wir können Strings mit einem Plus Symbol zusammensetzen, zum Beispiel: `"Hello" + "World"`. Genau das passiert hier, sodass `"1" + "2"` einen Wert von `"12"` zurück wirft.
+In diesem Beispiel wandelt JavaScript die Nummer `1` in einem String um, sodass die Funktion Sinn ergibt und einen Wert zurückgeben kann. Während der Addition eines numerischen Types (`1`) mit einem String (`'2'`) wird die Nummer wie ein String behandelt. Wir können Strings mit einem Plus Symbol zusammensetzen, zum Beispiel: `"Hello" + "World"`. Genau das passiert hier, sodass `"1" + "2"` einen Wert von `"12"` zurückgibt.
From 82aa62d22f4f350316aeb883d7d74c47260d2e2d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n?= <22575055+aguadotzn@users.noreply.github.com>
Date: Thu, 20 Jun 2019 16:34:22 +0200
Subject: [PATCH 026/881] Questions 20-30
---
README-ES.md | 114 +++++++++++++++++++++++++--------------------------
1 file changed, 57 insertions(+), 57 deletions(-)
diff --git a/README-ES.md b/README-ES.md
index e9cb0a1b..96b2c57c 100644
--- a/README-ES.md
+++ b/README-ES.md
@@ -631,7 +631,7 @@ Con `"use strict"`, es posible asegurarse de que no se declara accidentalmente v
---
-###### 21. What's value of `sum`?
+###### 21. ¿Cuál es el valor de `sum`?
```javascript
const sum = eval("10*10+5");
@@ -642,44 +642,44 @@ const sum = eval("10*10+5");
- C: `TypeError`
- D: `"10*10+5"`
-Answer
+Solución
-#### Answer: A
+#### Respuesta correcta: A
-`eval` evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is `10 * 10 + 5`. This returns the number `105`.
+`eval` evalúa los códigos que se pasan como una cadena. Si es una expresión, como en este caso, evalúa la expresión. La expresión es `10 * 10 + 5`. Esto devuelve el número `105`.
---
-###### 22. How long is cool_secret accessible?
+###### 22. ¿Cuánto tiempo es accesible cool_secret?
```javascript
sessionStorage.setItem("cool_secret", 123);
```
-- A: Forever, the data doesn't get lost.
-- B: When the user closes the tab.
-- C: When the user closes the entire browser, not only the tab.
-- D: When the user shuts off their computer.
+- A: Para siempre, los datos no se pierden.
+- B: Cuando el usuario cierra la pestaña.
+- C: Cuando el usuario cierra todo el navegador, no sólo la pestaña.
+- D: Cuando el usuario apaga su ordenador.
-Answer
+Solución
-#### Answer: B
+#### Respuesta correcta: B
-The data stored in `sessionStorage` is removed after closing the _tab_.
+Los datos almacenados en `sessionStorage` se eliminan después de cerrar la pestaña.
-If you used `localStorage`, the data would've been there forever, unless for example `localStorage.clear()` is invoked.
+Si se usó `localStorage`, los datos habrían estado allí siempre, a menos que por ejemplo `localStorage.clear()` sea invocado.
---
-###### 23. What's the output?
+###### 23. ¿Qué devuelve la siguiente función?
```javascript
var num = 8;
@@ -693,21 +693,21 @@ console.log(num);
- C: `SyntaxError`
- D: `ReferenceError`
-Answer
+Solución
-#### Answer: B
+#### Respuesta correcta: B
-With the `var` keyword, you can declare multiple variables with the same name. The variable will then hold the latest value.
+Con la palabra reservada `var`, se pueden declarar múltiples variables con el mismo nombre. La variable tendrá entonces el último valor.
-You cannot do this with `let` or `const` since they're block-scoped.
+No es posible hacer esto con `let` o `const` ya que tienen un alcance de bloque.
---
-###### 24. What's the output?
+###### 24. ¿Qué devuelve la siguiente función?
```javascript
const obj = { 1: "a", 2: "b", 3: "c" };
@@ -724,21 +724,22 @@ set.has(1);
- C: `true` `true` `false` `true`
- D: `true` `true` `true` `true`
-Answer
+Solución
-#### Answer: C
+#### Respuesta correcta: C
-All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
+Todas las claves de un objeto (excepto los símbolos) actúan como cadenas, incluso si no son escritas como una cadena. Es por eso que `obj.hasOwnProperty('1')` también devuelve verdadero.
+
+No funciona así para un conjunto. No hay un "1" en nuestro set: `set.has('1')` devuelve `falso`. Tiene el tipo numérico `1`, `set.has(1)` devuelve `true`.
-It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')` returns `false`. It has the numeric type `1`, `set.has(1)` returns `true`.
---
-###### 25. What's the output?
+###### 25. ¿Qué devuelve la siguiente función?
```javascript
const obj = { a: "one", b: "two", a: "three" };
@@ -750,37 +751,37 @@ console.log(obj);
- C: `{ a: "three", b: "two" }`
- D: `SyntaxError`
-Answer
+Solución
-#### Answer: C
+#### Respuesta correcta: C
-If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
+Si tiene dos claves con el mismo nombre, la clave será reemplazada. Seguirá estando en su primera posición, pero con el último valor especificado
---
-###### 26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
+###### 26. El contexto de ejecución de JS crea dos cosas: el objecto global y la palabra reservada "this".
- A: true
- B: false
- C: it depends
-Answer
+Solución
-#### Answer: A
+#### Respuesta correcta: A
-The base execution context is the global execution context: it's what's accessible everywhere in your code.
+El contexto de ejecución base es el contexto de ejecución global: es accesible en todo el código.
---
-###### 27. What's the output?
+###### 27. ¿Qué devuelve la siguiente función?
```javascript
for (let i = 1; i < 5; i++) {
@@ -794,19 +795,18 @@ for (let i = 1; i < 5; i++) {
- C: `1` `2` `4`
- D: `1` `3` `4`
-Answer
+Solución
-#### Answer: C
-
-The `continue` statement skips an iteration if a certain condition returns `true`.
+#### Respuesta correcta: C
+La sentencia `continue` omite una iteración si una cierta condición, en este caso `(i === 3)`, devuelve `true`.
---
-###### 28. What's the output?
+###### 28. ¿Qué devuelve la siguiente función?
```javascript
String.prototype.giveLydiaPizza = () => {
@@ -823,19 +823,19 @@ name.giveLydiaPizza();
- C: `SyntaxError`
- D: `undefined`
-Answer
+Solución
-#### Answer: A
+#### Respuesta correcta: A
-`String` is a built-in constructor, which we can add properties to. I just added a method to its prototype. Primitive strings are automatically converted into a string object, generated by the string prototype function. So, all strings (string objects) have access to that method!
+`String` es un constructor incorporado, al que podemos añadir propiedades. En este caso concreto, añadimos un método a su prototipo. Las cadenas primitivas se convierten automáticamente en un objeto de cadena, generado por la función de prototipo de cadena. Por lo tanto, todas las cadenas (objetos de cadena) tienen acceso a ese método.
---
-###### 29. What's the output?
+###### 29. ¿Qué devuelve la siguiente función?
```javascript
const a = {};
@@ -853,23 +853,23 @@ console.log(a[b]);
- C: `undefined`
- D: `ReferenceError`
-Answer
+Solución
-#### Answer: B
+#### Respuesta correcta: B
-Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`.
+Las claves se convierten automáticamente en strings. Estamos tratando en este pregunta de establecer un objeto como clave para el objeto `a`, con el valor de `123`.
-However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
+Sin embargo, cuando se _stringfy_ (compleja traducción) un objeto, se convierte en `"[Object object]"`. Así que lo que estamos diciendo aquí, es que `a["Object object"] = 123`. Entonces, podemos intentar hacer lo mismo de nuevo. `c` es otro objeto que estamos implícitamente encadenando. Entonces, `a["Object object"] = 456`.
-Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to `456`, so it returns `456`.
+Para finalizar, registramos `a[b]`, que en realidad es `a["Object"]`. Acabamos de ponerlo en `456`, así que devuelve `456`.
---
-###### 30. What's the output?
+###### 30. ¿Qué devuelve la siguiente función?
```javascript
const foo = () => console.log("First");
@@ -886,36 +886,36 @@ baz();
- C: `Second` `First` `Third`
- D: `Second` `Third` `First`
-Answer
+Solución
-#### Answer: B
+#### Respuesta correcta: B
-We have a `setTimeout` function and invoked it first. Yet, it was logged last.
+Tenemos una función `setTimeout` y la invocamos primero. Sin embargo, fue el último en ser registrado.
-This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
+Esto se debe a que en los navegadores, no sólo tenemos el motor de tiempo de ejecución, también tenemos algo llamado `WebAPI`. El `WebAPI` nos da la función `setTimeout` para empezar, y por ejemplo el DOM.
-After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
+Después de que la _callback_ es empujada a la WebAPI, la función `setTimeout` en sí misma (¡pero no la callback!) es removida de la pila.
-Now, `foo` gets invoked, and `"First"` is being logged.
+Ahora, `foo` es invocado, y ``"First"`` está siendo registrado.
-`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged.
+`Foo` se quita de la pila, y `Baz` es invocado. `Third` se registra.
-The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_.
+La WebAPI no puede simplemente añadir cosas a la pila cuando está lista. En su lugar, empuja la función de devolución de llamada a algo llamado la _queue_ (cola en español).
-This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
+Aquí es donde un bucle de eventos comienza a funcionar. Un **lazo de evento** mira la pila y la cola de tareas. Si la pila está vacía, toma lo primero que encuentra en la cola y la empuja sobre la pila.
-`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack.
+Se invoca el `bar`, se registra el ``"Second"`` y se quita de la pila.
From e5f5af03fb34c6b7cfb0d98ac91be655a9406ce5 Mon Sep 17 00:00:00 2001
From: panicdragon
Date: Fri, 21 Jun 2019 02:17:29 +0900
Subject: [PATCH 027/881] Translate to Japanese
---
README-ja_JA.md | 1335 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 1335 insertions(+)
create mode 100644 README-ja_JA.md
diff --git a/README-ja_JA.md b/README-ja_JA.md
new file mode 100644
index 00000000..9ffde70a
--- /dev/null
+++ b/README-ja_JA.md
@@ -0,0 +1,1335 @@
+# JavaScript (高度な) 問題集
+
+私は毎日、JavaScriptに関する選択問題を [Instagram](https://www.instagram.com/theavocoder)に投稿していますが、ここにも投稿します。
+
+初級から上級まで: JavaScriptの知識のテストを行ったり、知識を少し深めたり、コーディング面接の準備をしてください。:muscle: :rocket: 私はこのレポを毎週新しい質問で更新します。
+
+答えは質問の下の折りたたまれたセクションにあります、クリックすればそれを広げられます。幸運を祈ります。:heart:
+
+
+[中文版本](./README-zh_CN.md)
+[Русский](./README_ru-RU.md)
+[Western Balkan](./README-bs_BS.md)
+[Deutsch](./README-de_DE.md)
+[Tiếng Việt](./README-vi.md)
+[日本語](./README-ja_JA.md)
+
+---
+
+###### 1. 何が出力されるでしょうか?
+
+```javascript
+function sayHi() {
+ console.log(name);
+ console.log(age);
+ var name = "Lydia";
+ let age = 21;
+}
+
+sayHi();
+```
+
+- A: `Lydia` と `undefined`
+- B: `Lydia` と `ReferenceError`
+- C: `ReferenceError` と `21`
+- D: `undefined` と `ReferenceError`
+
+答え
+
+
+#### 答え: D
+
+関数内で、まず `var`キーワードを使って `name`変数を宣言します。これは、変数が定義されている行に実際に到達するまで、変数がデフォルト値の `undefined`で初期化される(作成時にメモリ空間が設定される)ことを意味します。
+
+`name`変数をログ出力を実行している行では、まだ変数を定義していませんので、`undefined`の値を保持しています。
+
+`let`キーワード(または`const`)を持つ変数は持ち上げられますが、 `var`とは異なり、初期化されません。それらを宣言(初期化)する行の前にはアクセスできません。これは"temporal dead zone"と呼ばれます。
+
+宣言される前に変数にアクセスしようとすると、JavaScriptは `ReferenceError`を投げます。
+
+
+
+
+---
+
+###### 2. 何が出力されるでしょうか?
+
+```javascript
+for (var i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+
+for (let i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+```
+
+- A: `0 1 2` と `0 1 2`
+- B: `0 1 2` と `3 3 3`
+- C: `3 3 3` と `0 1 2`
+
+答え
+
+
+#### 答え: C
+
+JavaScriptのイベントキューのため、`setTimeout`コールバック関数はループが実行された後に呼び出されます。最初のループの変数 `i`は`var`キーワードを使って宣言されているので、この値はグローバル変数となります。ループの間、単項演算子 `++`を使用して、毎回 `i`の値を`1`ずつインクリメントしました。 最初の例では `setTimeout`コールバック関数が呼び出されるまでに`i`は`3`となりました。
+
+2番目のループでは、変数 `i`が `let`キーワードを使って宣言されました。 `let`(または`const`)キーワードで宣言された変数はブロックスコープです(ブロックは `{}`の間のものです)。それぞれの繰り返しの間、 `i`は新しい値を持ち、それぞれの値はループの内側にあります。
+
+
+
+
+---
+
+###### 3. 何が出力されるでしょうか?
+
+```javascript
+const shape = {
+ radius: 10,
+ diameter() {
+ return this.radius * 2;
+ },
+ perimeter: () => 2 * Math.PI * this.radius
+};
+
+shape.diameter();
+shape.perimeter();
+```
+
+- A: `20` と `62.83185307179586`
+- B: `20` と `NaN`
+- C: `20` と `63`
+- D: `NaN` と `63`
+
+答え
+
+
+#### 答え: B
+
+`diameter`の値は正則関数であり、`perimeter`の値はアロー関数です。
+
+アロー関数では、`this`キーワードは通常の関数とは異なり、現在の周囲の範囲を参照します。これは、`perimeter`関数を呼ぶと、shapeオブジェクトではなく、その周囲の範囲(例えば window)を参照することを意味します。
+
+そのオブジェクトには`radius`という値はなく、`undefined`を返します。
+
+
+
+
+---
+
+###### 4. 何が出力されるでしょうか?
+
+```javascript
++true;
+!"Lydia";
+```
+
+- A: `1` と `false`
+- B: `false` と `NaN`
+- C: `false` と `false`
+
+答え
+
+
+#### 答え: A
+
+単項プラスは、オペランドを数値に変換しようとします。`true`は`1`、`false`は`0`です
+
+文字列「Lydia」は truthy valueです。ここで求めているのは、「このtruthy valueは、falsyなのか」ということです。これは `false`を返します。
+
+
+
+
+---
+
+###### 5. 正解はどれでしょう?
+
+```javascript
+const bird = {
+ size: "small"
+};
+
+const mouse = {
+ name: "Mickey",
+ small: true
+};
+```
+
+- A: `mouse.bird.size` is not valid
+- B: `mouse[bird.size]` is not valid
+- C: `mouse[bird["size"]]` is not valid
+- D: これらすべて有効です
+
+答え
+
+
+#### 答え: A
+
+JavaScriptでは、すべてのオブジェクトキーは文字列です(Symbolでない限り)。たとえそれを文字列として入力していなくても、それらは常にフードの下で文字列に変換されます。
+
+JavaScriptは、ステートメントを解釈(または、ボックス解除)します。大括弧表記を使用すると、最初の左大括弧 `[`を見て、右大括弧 `]`が見つかるまで進みます。その時だけ、そのステートメントを評価します。
+
+`mouse [bird.size]`: まず最初に、`bird.size`が評価されます。これは文字列の `"small"`となります。 `mouse["small"]`は、`true`を返します。
+
+しかし、ドット表記では、これは起こりません。 `mouse`は`bird`と呼ばれるキーを持っていません。 つまり`mouse.bird`は`undefined`となります。
+
+また、ドット表記を使って `size`を求めます: `mouse.bird.size`。 mouse.birdは未定義なので、実際にはundefined.sizeを要求しています。これは有効ではないので、`Cannot read property "size" of undefined`ような、エラーをスローします。
+
+
+
+
+---
+
+---
+
+###### 6. 何が出力されるでしょうか?
+
+```javascript
+let c = { greeting: "Hey!" };
+let d;
+
+d = c;
+c.greeting = "Hello";
+console.log(d.greeting);
+```
+
+- A: `Hello`
+- B: `Hey`
+- C: `undefined`
+- D: `ReferenceError`
+- E: `TypeError`
+
+答え
+
+
+#### 答え: A
+
+JavaScriptでは、すべてのオブジェクトは互いに等しく設定すると参照によって相互作用します。
+
+まず、変数`c`は、オブジェクトに対する値を保持します。その後、`c`オブジェクトに対して持っている値と同じ参照で`d`に代入します。
+
+
+
+1つのオブジェクトを変更すると、それらすべてが変更されます。
+
+
+
+
+---
+
+###### 7. 何が出力されるでしょうか?
+
+```javascript
+let a = 3;
+let b = new Number(3);
+let c = 3;
+
+console.log(a == b);
+console.log(a === b);
+console.log(b === c);
+```
+
+- A: `true` `false` `true`
+- B: `false` `false` `true`
+- C: `true` `false` `false`
+- D: `false` `true` `true`
+
+答え
+
+
+#### 答え: C
+
+`new Number()`は、組み込み関数のコンストラクタです。数字のように見えますが、実際には数字ではありません。たくさんの追加機能があり、それはオブジェクトとなります。
+
+`==`演算子を使うとき、同じ値を持っているかどうか? をチェックするだけとなります。それらは両方とも`3`の値を持っているので、それは`true`を返します。
+
+しかし、`===`演算子を使う時は、値と型は同じであるべきです。 そうでないので: `new Number()`は数値ではなく、**オブジェクト**となります。なので、両方ともfalseを返します。
+
+
+
+
+---
+
+###### 8. 何が出力されるでしょうか?
+
+```javascript
+class Chameleon {
+ static colorChange(newColor) {
+ this.newColor = newColor;
+ return this.newColor;
+ }
+
+ constructor({ newColor = "green" } = {}) {
+ this.newColor = newColor;
+ }
+}
+
+const freddie = new Chameleon({ newColor: "purple" });
+freddie.colorChange("orange");
+```
+
+- A: `orange`
+- B: `purple`
+- C: `green`
+- D: `TypeError`
+
+答え
+
+
+#### 答え: D
+
+`colorChange`関数は静的です。静的メソッドは、それらが作成されたコンストラクタ上でのみ動作するように設計されており、どの子達にも受け継がれません。 `freddie`は子となりますので、この関数は受け継がれず、`freddie`インスタンスでは利用できません。
+
+その結果、`TypeError`が投げられます。
+
+
+
+
+---
+
+###### 9. 何が出力されるでしょうか?
+
+```javascript
+let greeting;
+greetign = {}; // Typo!
+console.log(greetign);
+```
+
+- A: `{}`
+- B: `ReferenceError: greetign is not defined`
+- C: `undefined`
+
+答え
+
+
+#### 答え: A
+
+グローバルオブジェクトに、空のオブジェクトを作成したばかりなので、オブジェクトはログ出力されます。`greeting`を`greetign`と誤って入力した場合、JSインタプリタは実際にこれを `global.greetign = {}`(またはブラウザの `window.greetign = {}`)と見なします。
+
+これを避けるために、"use strict"を使用する事ができます。これにより、変数を何かに設定する前に、変数宣言したことを確認できます。
+
+
+
+
+---
+
+###### 10. これを行うと、どうなりますか?
+
+```javascript
+function bark() {
+ console.log("Woof!");
+}
+
+bark.animal = "dog";
+```
+
+- A: 何も起こらない、これは全く問題ない!
+- B: `SyntaxError`. この方法で関数にプロパティを追加することはできません。
+- C: `undefined`
+- D: `ReferenceError`
+
+答え
+
+
+#### 答え: A
+
+関数はオブジェクトとなるので、これはJavaScriptで可能です。(プリミティブ型以外はすべてオブジェクトです。)
+
+関数は特別な種類のオブジェクトです。自分で書いたコードは実際の機能ではありません。関数はプロパティを持つオブジェクトです。よって、このプロパティは呼び出し可能となります。
+
+
+
+
+---
+
+###### 11. 何が出力されるでしょうか?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const member = new Person("Lydia", "Hallie");
+Person.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+
+console.log(member.getFullName());
+```
+
+- A: `TypeError`
+- B: `SyntaxError`
+- C: `Lydia Hallie`
+- D: `undefined` `undefined`
+
+答え
+
+
+#### 答え: A
+
+通常のオブジェクトのようにコンストラクタにプロパティを追加することはできません。一度にすべてのオブジェクトに機能を追加したい場合は、代わりにプロトタイプを使用する必要があります。だからこの場合は、
+
+```js
+Person.prototype.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+```
+
+で、`member.getFullName()`が、機能するはずです。これはなぜ有益なのでしょうか。例えば、このメソッドをコンストラクタ自体に追加したとします。すべての`Person`インスタンスがこのメソッドを必要としなかったのかもしれません。
+
+その場合、多くのメモリスペースを浪費する事でしょう。なぜならそれらはまだその特性を持ち、それは各インスタンスのためにメモリスペースを消費するからです。
+
+その代わりに、プロトタイプに追加するだけであれば、メモリ内の1箇所に配置するだけで、すべてのユーザーがアクセスできます。
+
+
+
+
+---
+
+###### 12. 何が出力されるでしょうか?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const lydia = new Person("Lydia", "Hallie");
+const sarah = Person("Sarah", "Smith");
+
+console.log(lydia);
+console.log(sarah);
+```
+
+- A: `Person {firstName: "Lydia", lastName: "Hallie"}` と `undefined`
+- B: `Person {firstName: "Lydia", lastName: "Hallie"}` と `Person {firstName: "Sarah", lastName: "Smith"}`
+- C: `Person {firstName: "Lydia", lastName: "Hallie"}` と `{}`
+- D:`Person {firstName: "Lydia", lastName: "Hallie"}` と `ReferenceError`
+
+答え
+
+
+#### 答え: A
+
+`sarah`では、`new`キーワードを使いませんでした。`new`を使用した場合、作成した新しい空のオブジェクトを参照します。しかし、`new`を追加しなければ、それは**グローバルオブジェクト**を参照することとなります。
+
+`this.firstName`に`"Sarah"`を代入、`this.lastName`に`"Smith"`を代入したつもりでしたが、実際に行った事は、`global.firstName = 'Sarah'` と、`global.lastName = 'Smith'`を定義したのです。
+
+`sarah`自体は` undefined`のままです。
+
+
+
+
+---
+
+###### 13. イベント伝播の3つの段階はどれですか?
+
+- A: Target > Capturing > Bubbling
+- B: Bubbling > Target > Capturing
+- C: Target > Bubbling > Capturing
+- D: Capturing > Target > Bubbling
+
+答え
+
+
+#### 答え: D
+
+**capture**フェーズの間、イベントは先祖の要素を通過してターゲットの要素になります。それから**target**要素に達した後、**バブリング**が開始されます。
+
+
+
+
+
+
+---
+
+###### 14. すべてのオブジェクトはプロトタイプを持っています。
+
+- A: true
+- B: false
+
+答え
+
+
+#### 答え: B
+
+**基本オブジェクト**を除き、すべてのオブジェクトにプロトタイプがあります。ベースオブジェクトは`.toString`のようないくつかのメソッドとプロパティにアクセスできます。
+
+これが、組み込みのJavaScriptメソッドを使用できる理由です。このような方法はすべてプロトタイプで利用できます。
+
+JavaScriptはそれをあなたのオブジェクト上で直接見つけることはできませんが、プロトタイプチェーンをたどり、見つけます。
+
+
+
+
+---
+
+###### 15. 何が出力されるでしょうか?
+
+```javascript
+function sum(a, b) {
+ return a + b;
+}
+
+sum(1, "2");
+```
+
+- A: `NaN`
+- B: `TypeError`
+- C: `"12"`
+- D: `3`
+
+答え
+
+
+#### 答え: C
+
+JavaScriptは、**動的に型付けされた言語**です。: 特定の変数がどんな型であるかは指定しません。知らないうちに、値が自動的に別の型に変換されることがあります。この事を`implicit type coercion`と呼ばれてます。 **Coercion**は、ある型から別の型に変換しています。
+
+この例では、関数が意味を成して値を返すために、JavaScriptは数字の`1`を文字列に変換します。数値型(`1`)と 文字列型(`'2'`)の追加中は、数字は文字列として扱われます。
+
+`"Hello"+"World"`のように文字列を連結することができるので、ここで起こっているのは`"1"+"2"`で、これは `"12"`を返します。
+
+
+
+
+---
+
+###### 16. 何が出力されるでしょうか?
+
+```javascript
+let number = 0;
+console.log(number++);
+console.log(++number);
+console.log(number);
+```
+
+- A: `1` `1` `2`
+- B: `1` `2` `2`
+- C: `0` `2` `2`
+- D: `0` `1` `2`
+
+答え
+
+
+#### 答え: C
+
+**接尾辞** 単項演算子 `++`:
+
+1.値を返す(これは`0`を返す)
+2.値を増やす(numberは現在`1`です)
+
+**接頭辞** 単項演算子 `++`:
+
+1.値を増やす(数値は2になります)
+2.値を返す(これは`2`を返します)
+
+これは`0 2 2`を返します。
+
+
+
+
+---
+
+###### 17. 何が出力されるでしょうか?
+
+```javascript
+function getPersonInfo(one, two, three) {
+ console.log(one);
+ console.log(two);
+ console.log(three);
+}
+
+const person = "Lydia";
+const age = 21;
+
+getPersonInfo`${person} is ${age} years old`;
+```
+
+- A: `"Lydia"` `21` `["", " is ", " years old"]`
+- B: `["", " is ", " years old"]` `"Lydia"` `21`
+- C: `"Lydia"` `["", " is ", " years old"]` `21`
+
+答え
+
+
+#### 答え: B
+
+タグ付きテンプレートリテラルを使用する場合、最初の引数の値は常に文字列値の配列です。残りの引数は渡された式の値を取得します。
+
+
+
+
+---
+
+###### 18. 何が出力されるでしょうか?
+
+```javascript
+function checkAge(data) {
+ if (data === { age: 18 }) {
+ console.log("You are an adult!");
+ } else if (data == { age: 18 }) {
+ console.log("You are still an adult.");
+ } else {
+ console.log(`Hmm.. You don't have an age I guess`);
+ }
+}
+
+checkAge({ age: 18 });
+```
+
+- A: `You are an adult!`
+- B: `You are still an adult.`
+- C: `Hmm.. You don't have an age I guess`
+
+答え
+
+
+#### 答え: C
+
+等価性をテストするとき、プリミティブはそれらの値によって比較され、オブジェクトはそれらの参照によって比較されます。 JavaScriptは、オブジェクトがメモリ内の同じ場所への参照を持っているかどうかを確認します。
+
+比較している2つのオブジェクトにはそれがありません。パラメータとして渡したオブジェクトが、等価性を確認するために使用したオブジェクトとは異なるメモリ内の場所を参照しています。
+
+これが `{ age: 18 } === { age: 18 }`と、`{ age: 18 } == { age: 18 }`の両方が、`false`を返す理由です。
+
+
+
+
+---
+
+###### 19. 何が出力されるでしょうか?
+
+```javascript
+function getAge(...args) {
+ console.log(typeof args);
+}
+
+getAge(21);
+```
+
+- A: `"number"`
+- B: `"array"`
+- C: `"object"`
+- D: `"NaN"`
+
+答え
+
+
+#### 答え: C
+
+スプレッド演算子(`... args`.)は、引数付きの配列を返します。配列はオブジェクトなので、`typeof args`は、`"object"`を返します。
+
+
+
+
+---
+
+###### 20. 何が出力されるでしょうか?
+
+```javascript
+function getAge() {
+ "use strict";
+ age = 21;
+ console.log(age);
+}
+
+getAge();
+```
+
+- A: `21`
+- B: `undefined`
+- C: `ReferenceError`
+- D: `TypeError`
+
+答え
+
+
+#### 答え: C
+
+`"use strict"`を使うと、誤ってグローバル変数を宣言しないようにすることができます。変数`age`を宣言したことは一度もありませんし、`"use strict"`を使っているので参照エラーになります。
+
+`"use strict"`を使用しなかった場合は、プロパティ`age`がグローバルオブジェクトに追加されたことになるので、それは機能します。
+
+
+
+
+---
+
+###### 21. sumの値は何?
+
+```javascript
+const sum = eval("10*10+5");
+```
+
+- A: `105`
+- B: `"105"`
+- C: `TypeError`
+- D: `"10*10+5"`
+
+答え
+
+
+#### 答え: A
+
+`eval`は文字列として渡されたコードを評価します。この場合のように式であれば、その式を評価します。表現は`10 * 10 + 5`です。これは`105`を返します。
+
+
+
+
+---
+
+###### 22. cool_secretは、どのくらいの期間アクセス可能ですか?
+
+```javascript
+sessionStorage.setItem("cool_secret", 123);
+```
+
+- A: 永遠に、データが失われることはありません。
+- B: ユーザーがタブを閉じる時
+- C: ユーザーがタブだけでなくブラウザ全体を閉じる時。
+- D: ユーザーが自分のコンピュータをシャットダウンした時。
+
+答え
+
+
+#### 答え: B
+
+`sessionStorage`に格納されたデータは、タブを閉じた後に削除されます。
+
+`localStorage`を使用した場合は、`localStorage.clear()`などが呼び出されない限り、データは永久に存在しているでしょう。
+
+
+
+
+---
+
+###### 23. 何が出力されるでしょうか?
+
+```javascript
+var num = 8;
+var num = 10;
+
+console.log(num);
+```
+
+- A: `8`
+- B: `10`
+- C: `SyntaxError`
+- D: `ReferenceError`
+
+答え
+
+
+#### 答え: B
+
+`var`キーワードを使うと、同じ名前で複数の変数を宣言できます。変数は最新の値を保持します。
+
+ブロックスコープの`let`や`const`では、できません。
+
+
+
+
+---
+
+###### 24. 何が出力されるでしょうか?
+
+```javascript
+const obj = { 1: "a", 2: "b", 3: "c" };
+const set = new Set([1, 2, 3, 4, 5]);
+
+obj.hasOwnProperty("1");
+obj.hasOwnProperty(1);
+set.has("1");
+set.has(1);
+```
+
+- A: `false` `true` `false` `true`
+- B: `false` `true` `true` `true`
+- C: `true` `true` `false` `true`
+- D: `true` `true` `true` `true`
+
+答え
+
+
+#### 答え: C
+
+すべてのオブジェクトキー(Symbolsを除く)は、文字列として自分で入力しなくても、内部では文字列です。これが、`obj.hasOwnProperty('1')`もtrueを返す理由です。
+
+setではそうはいきません。上記のsetには`'1'` はありません: `set.has('1')`は、`false`を返します。数値型`1`の`set.has(1)`は、`true`を返します。
+
+
+
+
+---
+
+###### 25. 何が出力されるでしょうか?
+
+```javascript
+const obj = { a: "one", b: "two", a: "three" };
+console.log(obj);
+```
+
+- A: `{ a: "one", b: "two" }`
+- B: `{ b: "two", a: "three" }`
+- C: `{ a: "three", b: "two" }`
+- D: `SyntaxError`
+
+答え
+
+
+#### 答え: C
+
+同じ名前のキーが2つある場合、最初の位置にあるキーは置き換えられ、最後に指定された値になります。
+
+
+
+
+---
+
+###### 26. JavaScriptのglobal execution contextは、2つを作成します。: それはグローバルオブジェクトと "this"キーワードです。
+
+- A: true
+- B: false
+- C: 場合によりけり
+
+答え
+
+
+#### 答え: A
+
+基本的なexecution contextは、グローバルな実行コンテキストです。それはあなたのコードの至る所でアクセス可能なものです。
+
+
+
+
+---
+
+###### 27. 何が出力されるでしょうか?
+
+```javascript
+for (let i = 1; i < 5; i++) {
+ if (i === 3) continue;
+ console.log(i);
+}
+```
+
+- A: `1` `2`
+- B: `1` `2` `3`
+- C: `1` `2` `4`
+- D: `1` `3` `4`
+
+答え
+
+
+#### 答え: C
+
+`continue`ステートメントは、ある条件が`true`を返すと、繰り返し処理をスキップします。
+
+
+
+
+---
+
+###### 28. 何が出力されるでしょうか?
+
+```javascript
+String.prototype.giveLydiaPizza = () => {
+ return "Just give Lydia pizza already!";
+};
+
+const name = "Lydia";
+
+name.giveLydiaPizza();
+```
+
+- A: `"Just give Lydia pizza already!"`
+- B: `TypeError: not a function`
+- C: `SyntaxError`
+- D: `undefined`
+
+答え
+
+
+#### 答え: A
+
+`String`はプロパティを追加することができる組み込みコンストラクタです。プロトタイプにメソッドを追加しました。
+
+プリミティブ文字列は、文字列プロトタイプ関数によって生成された文字列オブジェクトに自動的に変換されます。
+
+つまり、すべての文字列(文字列オブジェクト)がそのメソッドにアクセスできます。
+
+
+
+
+---
+
+###### 29. 何が出力されるでしょうか?
+
+```javascript
+const a = {};
+const b = { key: "b" };
+const c = { key: "c" };
+
+a[b] = 123;
+a[c] = 456;
+
+console.log(a[b]);
+```
+
+- A: `123`
+- B: `456`
+- C: `undefined`
+- D: `ReferenceError`
+
+答え
+
+
+#### 答え: B
+
+オブジェクトキーは自動的に文字列に変換されます。オブジェクトaのキーとして、値123で設定しようとしています。
+
+しかし、オブジェクトを文字列化すると、それは`"[Object object]"`になってしまいます。なので、ここで行っているのは、 `a["Object object"] = 123`です。
+
+その後、同じことをもう一度試みています。`c`は暗黙のうちに文字列化している別のオブジェクトです。そのため、`a["Object object"] = 456`となります。
+
+その後、`a[b]`でログ出力。実際には`a["Object object"]`です。これを `456`に設定しただけなので、`456`を返します。
+
+
+
+
+---
+
+###### 30. 何が出力されるでしょうか?
+
+```javascript
+const foo = () => console.log("First");
+const bar = () => setTimeout(() => console.log("Second"));
+const baz = () => console.log("Third");
+
+bar();
+foo();
+baz();
+```
+
+- A: `First` `Second` `Third`
+- B: `First` `Third` `Second`
+- C: `Second` `First` `Third`
+- D: `Second` `Third` `First`
+
+答え
+
+
+#### 答え: B
+
+`setTimeout`関数があり、それを最初に呼び出したのですが、それは最後にログ出力されました。
+
+これは、ブラウザにはランタイムエンジンがあるだけでなく、`WebAPI`と呼ばれるものもあるからです。`WebAPI`は最初に`setTimeout`関数を与えてくれます。例えばDOMです。
+
+callbackがWebAPIにプッシュされた後、`setTimeout`関数自体(コールバックではありません!)がスタックからポップされます。
+
+
+
+今、`foo`が呼び出され、`"First"`が、ログ出力されています。
+
+
+
+`foo`がスタックからポップされ、`baz`が呼び出されます。`"Third"`が、ログ出力されます。
+
+
+
+WebAPIは、準備が整ったときにスタックに、なにかを追加することはできません。代わりに、コールバック関数を`queue`と呼ばれるものにプッシュします。
+
+
+
+event loopが機能し始めるところです。 **event loop**はスタックとタスクキューを調べます。スタックが空の場合は、キューの最初のものを取り出し、それをスタックにプッシュします。
+
+
+
+`bar`が呼び出され、`"Second"`がログ出力され、スタックからポップされます。
+
+
+
+
+---
+
+###### 31.ボタンをクリックしたときのevent.targetは何ですか?
+
+```html
+
+```
+
+- A: 外側 `div`
+- B: 内側 `div`
+- C: `button`
+- D: ネストしたすべての要素の配列
+
+答え
+
+
+#### 答え: C
+
+イベントを引き起こした最も深くネストした要素がイベントのターゲットとなります。`event.stopPropagation`でバブリングを止めることができます
+
+
+
+
+---
+
+
+###### 32. p要素をクリックすると、ログ出力はどうなりますか。
+
+```html
+
+```
+
+- A: `p` `div`
+- B: `div` `p`
+- C: `p`
+- D: `div`
+
+答え
+
+
+#### 答え: A
+
+`p`をクリックすると、`p`と`div`の2つのログが表示されます。イベント伝播中は、キャプチャ、ターゲット、バブリングの3つのフェーズがあります。
+
+デフォルトでは、イベントハンドラはバブリング段階で実行されます(`useCapture`を`true`に設定しない限り)。最も深くネストした要素から外側に向かって進みます。
+
+
+
+
+---
+
+###### 33. 何が出力されるでしょうか?
+
+```javascript
+const person = { name: "Lydia" };
+
+function sayHi(age) {
+ console.log(`${this.name} is ${age}`);
+}
+
+sayHi.call(person, 21);
+sayHi.bind(person, 21);
+```
+
+- A: `undefined is 21` `Lydia is 21`
+- B: `function` `function`
+- C: `Lydia is 21` `Lydia is 21`
+- D: `Lydia is 21` `function`
+
+答え
+
+
+#### 答え: D
+
+両方とも、`this`キーワードが参照したいオブジェクトを渡すことができます。しかし、`.call`もすぐに実行されます。
+
+`.bind.`は関数のコピーを返しますが、コンテキストは束縛されています。すぐには実行されません。
+
+
+
+
+---
+
+###### 34. 何が出力されるでしょうか?
+
+```javascript
+function sayHi() {
+ return (() => 0)();
+}
+
+typeof sayHi();
+```
+
+- A: `"object"`
+- B: `"number"`
+- C: `"function"`
+- D: `"undefined"`
+
+答え
+
+
+#### 答え: B
+
+`sayHi`関数は、即時呼び出し関数式(IIFE)の戻り値を返します。この関数は`0`を返しました。それは`"number"`型です。
+
+参考:7つの組み込み型しかありません: `null`, `undefined`, `boolean`, `number`, `string`, `object`, そして`symbol`。関数はオブジェクトなので、`"function"`型ではなく`"object"`型です。
+
+
+
+
+---
+
+###### 35. これらの値のどれがfalsyですか?
+
+```javascript
+0;
+new Number(0);
+("");
+(" ");
+new Boolean(false);
+undefined;
+```
+
+- A: `0`, `''`, `undefined`
+- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
+- C: `0`, `''`, `new Boolean(false)`, `undefined`
+- D: これらすべてfalsy
+
+答え
+
+
+#### 答え: A
+
+falsyの値は6つだけです。
+
+- `undefined`
+- `null`
+- `NaN`
+- `0`
+- `''` (empty string)
+- `false`
+
+`new Number`や、`new Boolean`のような関数コンストラクタはtruthyです。
+
+
+
+
+---
+
+###### 36. 何が出力されるでしょうか?
+
+```javascript
+console.log(typeof typeof 1);
+```
+
+- A: `"number"`
+- B: `"string"`
+- C: `"object"`
+- D: `"undefined"`
+
+答え
+
+
+#### 答え: B
+
+`typeof 1`は、`"number"`を返します。
+
+`typeof "number"`は、`"string"`を返します。
+
+
+
+
+---
+
+###### 37. 何が出力されるでしょうか?
+
+```javascript
+const numbers = [1, 2, 3];
+numbers[10] = 11;
+console.log(numbers);
+```
+
+- A: `[1, 2, 3, 7 x null, 11]`
+- B: `[1, 2, 3, 11]`
+- C: `[1, 2, 3, 7 x empty, 11]`
+- D: `SyntaxError`
+
+答え
+
+
+#### 答え: C
+
+配列の長さを超える値を配列内の要素に設定すると、JavaScriptでは、"empty slots"と呼ばれるものを作成します。これらは実際には、`undefined`の値を持ちますが、あなたは以下のようなものを見るでしょう
+
+`[1, 2, 3, 7 x empty, 11]`
+
+実行場所によって異なります(browser、nodeなどによって異なります)。
+
+
+
+
+---
+
+###### 38. 何が出力されるでしょうか?
+
+```javascript
+(() => {
+ let x, y;
+ try {
+ throw new Error();
+ } catch (x) {
+ (x = 1), (y = 2);
+ console.log(x);
+ }
+ console.log(x);
+ console.log(y);
+})();
+```
+
+- A: `1` `undefined` `2`
+- B: `undefined` `undefined` `undefined`
+- C: `1` `1` `2`
+- D: `1` `undefined` `undefined`
+
+答え
+
+
+#### 答え: A
+
+`catch`ブロックは引数`x`を受け取ります。これは引数を渡すときの変数と同じ`x`ではありません。この変数`x`はブロックスコープです。
+
+後に、このブロックスコープ変数を`1`に設定し、変数`y`の値を設定します。ここで、ブロックスコープ変数`x`をログ出力します。これは`1`となります。
+
+`catch`ブロック以外では、`x`は未定義、`y`は2です。 `catch`ブロックの外側で`console.log(x)`した場合は、`undefined`を返し、`y`は`2`を返します。
+
+
+
+
+---
+
+###### 39. JavaScriptのすべてはどちらかです...
+
+- A: primitive か object
+- B: function か object
+- C: ひっかけ問題! objectsのみ
+- D: number か object
+
+答え
+
+
+#### 答え: A
+
+JavaScriptにはプリミティブ型とオブジェクトしかありません。
+
+プリミティブ型は、`boolean`, `null`, `undefined`, `bigint`, `number`, `string`, そして`symbol`です。
+
+プリミティブとオブジェクトを区別するのは、プリミティブにはプロパティもメソッドもないということです。
+
+ただし、`'foo'.toUpperCase()`は`'FOO'`と評価され、`TypeError`にはなりません。これは、文字列のようなプリミティブのプロパティやメソッドにアクセスしようとすると、JavaScriptがラッパークラスの1つ、すなわち`String`を使ってオブジェクトを暗黙的にラップし、式が評価された後ラッパーを直ちに破棄するためです。
+
+`null`と`undefined`を除くすべてのプリミティブはこの振る舞いをします。
+
+
+
+
+---
+
+###### 40. 何が出力されるでしょうか?
+
+```javascript
+[[0, 1], [2, 3]].reduce(
+ (acc, cur) => {
+ return acc.concat(cur);
+ },
+ [1, 2]
+);
+```
+
+- A: `[0, 1, 2, 3, 1, 2]`
+- B: `[6, 1, 2]`
+- C: `[1, 2, 0, 1, 2, 3]`
+- D: `[1, 2, 6]`
+
+答え
+
+
+#### 答え: C
+
+`[1,2]`は初期値です。これが最初の値で、一番最初の`acc`の値です。最初の周回の間、`acc`は`[1,2]`で、`cur`は`[0,1]`です。それらを連結すると、結果として`[1、2、0、1]`となります。
+
+そして、`[1, 2, 0, 1]`の`acc`と`[2, 3]`の`cur`を連結して`[1, 2, 0, 1, 2, 3]`を得ます
+
+
+
+
+---
+
+###### 41. 何が出力されるでしょうか?
+
+```javascript
+!!null;
+!!"";
+!!1;
+```
+
+- A: `false` `true` `false`
+- B: `false` `false` `true`
+- C: `false` `true` `true`
+- D: `true` `true` `false`
+
+答え
+
+
+#### 答え: B
+
+`null`はfalsyです。`!null`は`true`を返します。`!true`は`false`を返します。
+
+`""`はfalsyです。`!""`は`true`を返します。`!true`は`false`を返します。
+
+`1`はtruthyです。`!1`は`false`を返します。`!false`は`true`を返します。
+
+
+
+
+---
+
+
+###### 42. `setInterval`メソッドはブラウザに何を返しますか?
+
+```javascript
+setInterval(() => console.log("Hi"), 1000);
+```
+
+- A: ユニークid
+- B: 指定されたミリ秒数
+- C: 渡された関数
+- D: `undefined`
+
+答え
+
+
+#### 答え: A
+
+一意のIDを返します。このIDは `clearInterval()`関数で、その間隔をクリアするために使うことができます。
+
+
+
+
+---
+
+###### 43. これは何を返しますか?
+
+```javascript
+[..."Lydia"];
+```
+
+- A: `["L", "y", "d", "i", "a"]`
+- B: `["Lydia"]`
+- C: `[[], "Lydia"]`
+- D: `[["L", "y", "d", "i", "a"]]`
+
+答え
+
+
+#### 答え: A
+
+文字列はイテラブルです。スプレッド演算子は、イテラブルのすべての文字を1つの要素にマッピングします。
+
+
+
From 3f3bc2fb05cb57eb620dfd4b9bc8bb035bebe78b Mon Sep 17 00:00:00 2001
From: Guilherme Nogara
Date: Thu, 20 Jun 2019 16:00:30 -0300
Subject: [PATCH 028/881] Questions 16-43 done
---
README_pt_BR.md | 327 ++++++++++++++++++++++++------------------------
1 file changed, 164 insertions(+), 163 deletions(-)
diff --git a/README_pt_BR.md b/README_pt_BR.md
index 0c5ab777..5be1c3c5 100644
--- a/README_pt_BR.md
+++ b/README_pt_BR.md
@@ -427,6 +427,7 @@ Afirmamos que `this.firstName` vale `"Sarah"` e `this.lastName` vale `"Smith"`.
#### Resposta: D
Durate a fase do **capturing**, o evento percorre os elementos pais até chegar no elemento algo. Isso alcança o elemento **target**, e o **bubbling** começa.
+ ##### *Nota do tradutor: _bubbling_ descreve uma forma específica de propagação de eventos. Em tradução livre é "borbulhar", que indica como os eventos "sobem" a cadeia onde estão aninhados, mas prefiro por manter o original, visto que é o nome dessa forma de propagação.
@@ -452,7 +453,7 @@ Todos objetos tem protótipos, exceto pelo **base object**. O base object tem ac
---
-###### 15. What's the output?
+###### 15. Qual é a saída?
```javascript
function sum(a, b) {
@@ -467,21 +468,21 @@ sum(1, "2");
- C: `"12"`
- D: `3`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-JavaScript is a **dynamically typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
+JavaScript é uma **linguagem dinamicamente tipada**: Não especificamos quais tipos nossas variáveis são. Valores pode ser automaticamente convertidos em outro tipo sem você saber, o que é chamado de coerção implicita de tipo. **Coerção** é converter de um tipo em outro.
-In this example, JavaScript converts the number `1` into a string, in order for the function to make sense and return a value. During the addition of a numeric type (`1`) and a string type (`'2'`), the number is treated as a string. We can concatenate strings like `"Hello" + "World"`, so what's happening here is `"1" + "2"` which returns `"12"`.
+Nesse exemplo, JavaScript converte o número `1` em uma string, para que a função faça sentido e retorne um valor. Durante a adição de um tipo numérico (`1`) e uma string (`'2'`), o número é tratado como uma string. Podemos concatenar strings como `"Hello" + "World"`, então o que está acontecendo aqui é `"1" + "2"` que retorna `"12"`.
---
-###### 16. What's the output?
+###### 16. Qual é a saída?
```javascript
let number = 0;
@@ -495,29 +496,29 @@ console.log(number);
- C: `0` `2` `2`
- D: `0` `1` `2`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-The **postfix** unary operator `++`:
+O operador unário no **sufixo** `++`:
-1. Returns the value (this returns `0`)
-2. Increments the value (number is now `1`)
+1. Retorna o valor (retorna o valor `0`)
+2. Incrementa o valor (numero agora é `1`)
-The **prefix** unary operator `++`:
+O operador unário **prefixo** `++`:
-1. Increments the value (number is now `2`)
-2. Returns the value (this returns `2`)
+1. Incrementa o valor (numero agora é `2`)
+2. Retorna o valor (Retorna o valor `2`)
-This returns `0 2 2`.
+Isso retorna `0 2 2`.
---
-###### 17. What's the output?
+###### 17. Qual é a saída?
```javascript
function getPersonInfo(one, two, three) {
@@ -536,19 +537,19 @@ getPersonInfo`${person} is ${age} years old`;
- B: `["", " is ", " years old"]` `"Lydia"` `21`
- C: `"Lydia"` `["", " is ", " years old"]` `21`
-Answer
+Resposta
-#### Answer: B
+#### Resposta: B
-If you use tagged template literals, the value of the first argument is always an array of the string values. The remaining arguments get the values of the passed expressions!
+Se usamos template literals marcadas, ou tagged template literals, o valor do primeiro argumento é sempre um array com a string, separada pelos tagged template liberals. Os argumentos restantes recebem os valores das expressões passadas!
---
-###### 18. What's the output?
+###### 18. Qual é a saída?
```javascript
function checkAge(data) {
@@ -568,23 +569,23 @@ checkAge({ age: 18 });
- B: `You are still an adult.`
- C: `Hmm.. You don't have an age I guess`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-When testing equality, primitives are compared by their _value_, while objects are compared by their _reference_. JavaScript checks if the objects have a reference to the same location in memory.
+Quando testamos igualdade, primitivos são comparados por seus _valores_, enquanto objetos são comparados por suas _referências_. O JavaScript confere se os objetos tem a referência para o mesmo local na memória.
-The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
+Os dois objetos que estamos comparando não são assim: O objeto que passamos como parâmetro faz referência a uma posição na memória diferente daquela que o objeto que usamos para conferir a igualdade.
-This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }` return `false`.
+É por isso que ambos `{ age: 18 } === { age: 18 }` E `{ age: 18 } == { age: 18 }` retornam `false`.
---
-###### 19. What's the output?
+###### 19. Qual é a saída?
```javascript
function getAge(...args) {
@@ -599,19 +600,19 @@ getAge(21);
- C: `"object"`
- D: `"NaN"`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
+O operador _spread_ (`...args`.) retorna um array com os argumentos. Um array é um objeto, então `typeof args` retorna `"object"`
---
-###### 20. What's the output?
+###### 20. Qual é a saída?
```javascript
function getAge() {
@@ -628,19 +629,19 @@ getAge();
- C: `ReferenceError`
- D: `TypeError`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. If we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
+Com `"use strict"`, você pode ter certeza que não declarou variáveis globais. Nunca declaramos a variável `age`, e já que usamos `"use strict"`, ira gerar um erro de referência. Se não tivéssemos usado `"use strict"`, teria funcionado, uma vez que a propriedade `age` teria sido adicionada ao objeto global.
---
-###### 21. What's value of `sum`?
+###### 21. Qual o valor de `sum`?
```javascript
const sum = eval("10*10+5");
@@ -651,44 +652,44 @@ const sum = eval("10*10+5");
- C: `TypeError`
- D: `"10*10+5"`
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-`eval` evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is `10 * 10 + 5`. This returns the number `105`.
+`eval` executa o código mesmo se passado como string. Se é uma expressão, como nesse caso, ele cálcula a expressão. A expressão é `10 * 10 + 5`. Isso retorna o número `105`.
---
-###### 22. How long is cool_secret accessible?
+###### 22. Por quanto tempo cool_secret é acessível?
```javascript
sessionStorage.setItem("cool_secret", 123);
```
-- A: Forever, the data doesn't get lost.
-- B: When the user closes the tab.
-- C: When the user closes the entire browser, not only the tab.
-- D: When the user shuts off their computer.
+- A: Sempre, o dado não é perdido.
+- B: Quando o usuário fechar a guia.
+- C: Quando o usuário fechar o navegador inteiro.
+- D: Quando o usuário desligar o computador.
-Answer
+Resposta
-#### Answer: B
+#### Resposta: B
-The data stored in `sessionStorage` is removed after closing the _tab_.
+Dados guardados em `sessionStorage` são removidos depois de fechar a _guia_.
-If you used `localStorage`, the data would've been there forever, unless for example `localStorage.clear()` is invoked.
+Se usássemos `localStorage`, o dado seria guardado para sempre, exceto se `localStorage.clear()` fosse chamado.
---
-###### 23. What's the output?
+###### 23. Qual é a saída?
```javascript
var num = 8;
@@ -702,21 +703,21 @@ console.log(num);
- C: `SyntaxError`
- D: `ReferenceError`
-Answer
+Resposta
-#### Answer: B
+#### Resposta: B
-With the `var` keyword, you can declare multiple variables with the same name. The variable will then hold the latest value.
+Coma a palavra-chave `var`, você pode declarar várias variáveis com o mesmo nome. A variável vai guardar o último valor.
-You cannot do this with `let` or `const` since they're block-scoped.
+Você não pode fazer isso com `let` ou `const` uma vez que eles conferem o bloco de escopo em que estão inseridos.
---
-###### 24. What's the output?
+###### 24. Qual é a saída?
```javascript
const obj = { 1: "a", 2: "b", 3: "c" };
@@ -733,21 +734,21 @@ set.has(1);
- C: `true` `true` `false` `true`
- D: `true` `true` `true` `true`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
+Todas as chaves de objetos (exceto símbolos) são strings debaixo do capô, mesmo que você não digite como uma string. É por isso que `obj.hasOwnProperty('1')` também retorna `true`.
-It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')` returns `false`. It has the numeric type `1`, `set.has(1)` returns `true`.
+Não funciona assim para `Set`. Não tem um `'1'` no nosso set: `set.has('1')` retorna `false`. Temos o tipo número `1`, então `set.has(1)` retorna `true`.
---
-###### 25. What's the output?
+###### 25. Qual é a saída?
```javascript
const obj = { a: "one", b: "two", a: "three" };
@@ -759,37 +760,37 @@ console.log(obj);
- C: `{ a: "three", b: "two" }`
- D: `SyntaxError`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
+Se temos duas chaves com o mesmo nome, a última irá substituir a primeira. Ainda vai estar na primeira posição, mas com o último valor específicado.
---
-###### 26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
+###### 26. O contexto glogal de execução do JavaScrit cria duas coisas para você: O objeto glogal, e a palavra-chave `this`.
-- A: true
-- B: false
-- C: it depends
+- A: Verdadeiro
+- B: Falso
+- C: Depende
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-The base execution context is the global execution context: it's what's accessible everywhere in your code.
+O contexto base de execução é o contexto glogal: É aquilo que está acessível em qualquer lugar do código.
---
-###### 27. What's the output?
+###### 27. Qual é a saída?
```javascript
for (let i = 1; i < 5; i++) {
@@ -803,19 +804,19 @@ for (let i = 1; i < 5; i++) {
- C: `1` `2` `4`
- D: `1` `3` `4`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-The `continue` statement skips an iteration if a certain condition returns `true`.
+A palavra-chave `continue` pula uma iteração se a condição retorna `true`.
---
-###### 28. What's the output?
+###### 28. Qual é a saída?
```javascript
String.prototype.giveLydiaPizza = () => {
@@ -832,19 +833,19 @@ name.giveLydiaPizza();
- C: `SyntaxError`
- D: `undefined`
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-`String` is a built-in constructor, which we can add properties to. I just added a method to its prototype. Primitive strings are automatically converted into a string object, generated by the string prototype function. So, all strings (string objects) have access to that method!
+`String` é um construtor embutido, no qual podemos adicionar propriedades. Nesse caso adicionamos um método ao seu protótipo. Tipos primitivos `string` são automaticamente convertidos em um objeto string, gerado pelo construtor `String`. Assim, todas as strings (que são objetos string) tem acesso ao método.
---
-###### 29. What's the output?
+###### 29. Qual é a saída?
```javascript
const a = {};
@@ -862,23 +863,23 @@ console.log(a[b]);
- C: `undefined`
- D: `ReferenceError`
-Answer
+Resposta
-#### Answer: B
+#### Resposta: B
-Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`.
+Chaves de objeto são automaticamente convertidas em strings. Estamos tentando usar um objeto como chave do objeto `a`, com o valor de `123`.
-However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
+Contudo, quando transformamos um objeto em string, ele vira um `"[Object object]"`. Então, o que estamos afirmando é `a["Object object"] = 123`. Após, tentamos a mesma coisa. `c` é outro objeto que (implicitamente) convertemos para string. Então, temos `a["Object object"] = 456`.
-Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to `456`, so it returns `456`.
+Então, fazemos o log de `a[b]`, o que na verdade é `a["Object object"]`. Acabmos de definir esse valor, como `456`, e é isso que ele retorna.
---
-###### 30. What's the output?
+###### 30. Qual é a saída?
```javascript
const foo = () => console.log("First");
@@ -895,43 +896,43 @@ baz();
- C: `Second` `First` `Third`
- D: `Second` `Third` `First`
-Answer
+Resposta
-#### Answer: B
+#### Resposta: B
-We have a `setTimeout` function and invoked it first. Yet, it was logged last.
+Temos a função `setTimeout` e a invocamos por primeiro. Ainda assim, apareceu no log por último.
-This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
+Isso acontece pois nos navegadores, não temos apenas o nosso mecanismo de execução (runtime engine), temos também algo chamado `WebAPI`. A `WebAPI` nos da coisas como a `setTimeout` e o DOM.
-After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
+Depois que a função de retorno (callback) é enviada para a `WebAPI`, a função `setTimeout` (mas não seu retorno ou callback) são enviadas para fora do stack.
-Now, `foo` gets invoked, and `"First"` is being logged.
+Agora, `foo` é chamada, e `"First"` é adicionado ao log.
-`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged.
+`foo` é evniada para fora do stack, e `baz` é chamada. `"Third"` é adicionado ao log.
-The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_.
+A `WebAPI` não pode simplesmente adicionar coisas ao stack sempre que ficam prontas. Ao invés, disso, todo retorno que fica pronto é enviado para algo chamado _queue_.
-This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
+É aqui que um laço de evento começa a ocorrer. Um **laço de evento** confere o stack e o _queue_. Se o stack está livre, pega a primeira coisa que estiver na queue e coloca no stack.
-`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack.
+`bar` é chamada, `"Second"` é adicionado ao log, e é enviado para fora do stack.
---
-###### 31. What is the event.target when clicking the button?
+###### 31. qual é o event.target quando clicamos no botão?
```html
@@ -943,24 +944,24 @@ This is where an event loop starts to work. An **event loop** looks at the stack
```
-- A: Outer `div`
-- B: Inner `div`
+- A: A `div` mais externa
+- B: A `div` mais interna
- C: `button`
-- D: An array of all nested elements.
+- D: Um array dos elementos aninhandos.
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+O elemento mais interno no aninhamento que causou o evento é o alvo do evento. Você pode parar o _bubbling_ com `event.stopPropagation`.
---
-###### 32. When you click the paragraph, what's the logged output?
+###### 32. Quando você clica no parágrafo, O que é adicionado ao log?
```html
@@ -975,19 +976,19 @@ The deepest nested element that caused the event is the target of the event. You
- C: `p`
- D: `div`
-
Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
+Se clicarmos em `p`, veremos dois itens adicionaos ao log: `p` e `div`. Durante a propagação de eventos, existem 3 fases: capturar, adquirir o _target_, e o bubbling. Por padrão, manipuladores de eventos são executados junto a fase de bubbling (a não ser que você marque `useCapture` como `true`). Percorre do elemento aninhando mais interno, propagando para fora.
---
-###### 33. What's the output?
+###### 33. Qual é a saída?
```javascript
const person = { name: "Lydia" };
@@ -1005,21 +1006,21 @@ sayHi.bind(person, 21);
- C: `Lydia is 21` `Lydia is 21`
- D: `Lydia is 21` `function`
-Answer
+Resposta
-#### Answer: D
+#### Resposta: D
-With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
+Com ambos, podemos passar o objeto que queremos que o `this`faça referência. Contudo, `.call` é _executado imediatamente_!
-`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
+`.bind.` retorna uma _cópia_ da função, mas com seu contexto vinculado à cópia. E não é executado imediatamente.
---
-###### 34. What's the output?
+###### 34. Qual é a saída?
```javascript
function sayHi() {
@@ -1034,21 +1035,21 @@ typeof sayHi();
- C: `"function"`
- D: `"undefined"`
-Answer
+Resposta
-#### Answer: B
+#### Resposta: B
-The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+A função `sayHi` retorna o valor retornado pela arrow function pois ela é uma IIFE (Immediately Invoked Function Expression ou Expressão de Função Invocada Imediatamente). Essa IIFE retornou `0`, que é do tipo `"number"`.
-FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+Para saber mais: Só existem 7 tipos já definidos: `null`, `undefined`, `boolean`, `number`, `string`, `object`, e `symbol`. `"function"` não é um tipo, uma vez que funções são objetos, elas são do tipo `"object"`.
---
-###### 35. Which of these values are falsy?
+###### 35. Qual desses tem valor falsy?
```javascript
0;
@@ -1062,30 +1063,30 @@ undefined;
- A: `0`, `''`, `undefined`
- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
- C: `0`, `''`, `new Boolean(false)`, `undefined`
-- D: All of them are falsy
+- D: Todos são falsy
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-There are only six falsy values:
+Existem somente seis valores falsy:
- `undefined`
- `null`
- `NaN`
- `0`
-- `''` (empty string)
+- `''` (string vazia)
- `false`
-Function constructors, like `new Number` and `new Boolean` are truthy.
+Funções construtoras, como `new Number` e `new Boolean` são truthy.
---
-###### 36. What's the output?
+###### 36. Qual é a sáida?
```javascript
console.log(typeof typeof 1);
@@ -1096,20 +1097,20 @@ console.log(typeof typeof 1);
- C: `"object"`
- D: `"undefined"`
-Answer
+Resposta
-#### Answer: B
+#### Resposta: B
-`typeof 1` returns `"number"`.
-`typeof "number"` returns `"string"`
+`typeof 1` retorna `"number"`.
+`typeof "number"` retorna `"string"`
---
-###### 37. What's the output?
+###### 37. Qual é a saída?
```javascript
const numbers = [1, 2, 3];
@@ -1159,46 +1160,46 @@ depending on where you run it (it's different for every browser, node, etc.)
- C: `1` `1` `2`
- D: `1` `undefined` `undefined`
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
+O bloco do `catch` recebe o argumento `x`. Esse não é o mesmo `x` da variável de quando estamos passando os argumentos. A variável `x` é de escopo do seu bloco.
-Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+Depois, definimos essa variável, dentro do seu bloco, para valor `1`, e definimos o valor de `y`, que pertence a um bloco maior. Agora, nos adicionamos ao log o valor de `x`, que dentro desse bloco tem valor `1`.
-Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+Fora do bloco do `catch`. `x` ainda é `undefined`, e `y` ainda é `2`. Quando tentamos usar `console.log(x)` fora do bloco do `catch`, isso retorna `undefined`, e `y` retorna `2`.
---
-###### 39. Everything in JavaScript is either a...
+###### 39. Tudo em JavaScript ou é um...
-- A: primitive or object
-- B: function or object
-- C: trick question! only objects
-- D: number or object
+- A: primitivo ou um objeto
+- B: função ou um object
+- C: Pegadinha! Somente objetos
+- D: número ou um objeto
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-JavaScript only has primitive types and objects.
+JavaScript tem somente tipos primitivos e objetos.
-Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+Tipos primitivos são `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, e `symbol`.
-What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+O que diferencia um primitivo de um objeto é que primitivos não métodos ou propriedades. Contudo, se você está atento vai lembrar que `'foo'.toUpperCase()` retorna `'FOO'` e não resulta em um `TypeError`. Isso acontece pois quando você tenta acessar uma propriedade ou método em um primitivo como, por exemplo, uma string, JavaScript vai transformar esse primitivo em objeto usando um _wrapper_, nesse caso o `String`, e discarta o wrapper imediatamente após executar o método ou propriedade. Todos os primitivos, com exceção de `null` e `undefined` exibem esse comportamento.
---
-###### 40. What's the output?
+###### 40. Qual é a saída?
```javascript
[[0, 1], [2, 3]].reduce(
@@ -1214,21 +1215,21 @@ What differentiates a primitive from an object is that primitives do not have an
- C: `[1, 2, 0, 1, 2, 3]`
- D: `[1, 2, 6]`
-Answer
+Resposta
-#### Answer: C
+#### Resposta: C
-`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
+`[1, 2]` é nosso valor inicial. É o valor que começamos, e portanto o valor do primeiro `acc`. Durante a primeira iteração, `acc` é `[1,2]`, e `cur` é `[0, 1]`. Nós concatemos ambos, o que resulta em `[1, 2, 0, 1]`.
-Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
+Então, `[1, 2, 0, 1]` é `acc` e `[2, 3]` é o `cur`. Concatenamos novamente, e chegamos em `[1, 2, 0, 1, 2, 3]`.
---
-###### 41. What's the output?
+###### 41. Qual é a saída?
```javascript
!!null;
@@ -1241,46 +1242,46 @@ Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and ge
- C: `false` `true` `true`
- D: `true` `true` `false`
-Answer
+Resposta
-#### Answer: B
+#### Resposta: B
-`null` is falsy. `!null` returns `true`. `!true` returns `false`.
+`null` é falsy. `!null` retorna `true`. `!true` retorna `false`.
-`""` is falsy. `!""` returns `true`. `!true` returns `false`.
+`""` é falsy. `!""` retorna `true`. `!true` retorna `false`.
-`1` is truthy. `!1` returns `false`. `!false` returns `true`.
+`1` é truthy. `!1` retorna `false`. `!false` retorna `true`.
---
-###### 42. What does the `setInterval` method return in the browser?
+###### 42. O que o método `setInterval` retorna no navegador?
```javascript
setInterval(() => console.log("Hi"), 1000);
```
-- A: a unique id
-- B: the amount of milliseconds specified
-- C: the passed function
+- A: um id único
+- B: a quantidade de millisegundos especificada
+- C: a função passada
- D: `undefined`
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function.
+Retorna um id único. Esse id pode ser usado para limpar o intervalo com a função `clearInterval()`.
---
-###### 43. What does this return?
+###### 43. Qual é o retorno?
```javascript
[..."Lydia"];
@@ -1291,12 +1292,12 @@ It returns a unique id. This id can be used to clear that interval with the `cle
- C: `[[], "Lydia"]`
- D: `[["L", "y", "d", "i", "a"]]`
-Answer
+Resposta
-#### Answer: A
+#### Resposta: A
-A string is an iterable. The spread operator maps every character of an iterable to one element.
+Strings são iteráveis. O operador do spread `...` mapeia todo caractére de um iterável para um elemento.
From 78a9a84925deb542d95e37873916cef9bb309303 Mon Sep 17 00:00:00 2001
From: Guilherme Nogara
Date: Thu, 20 Jun 2019 16:08:07 -0300
Subject: [PATCH 029/881] Small typo correction
---
README_pt_BR.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README_pt_BR.md b/README_pt_BR.md
index 5be1c3c5..64bd9504 100644
--- a/README_pt_BR.md
+++ b/README_pt_BR.md
@@ -178,7 +178,7 @@ Por outro lado, com a notação de ponto `.`, isso não acontece. `mouse` não t
---
-###### 6. Quais são as saídas?
+###### 6. Qual é a saída?
```javascript
let c = { greeting: "Hey!" };
@@ -1139,7 +1139,7 @@ depending on where you run it (it's different for every browser, node, etc.)
---
-###### 38. What's the output?
+###### 38. Qual é a saída?
```javascript
(() => {
From f7a2bf540b1d0f26c51a9d7c1d1df60bce254fc5 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 20 Jun 2019 22:26:24 +0200
Subject: [PATCH 030/881] Start to translate answers in French and rename
french README
---
README-fr.md => README_fr-FR.md | 46 ++++++++++++++++-----------------
1 file changed, 23 insertions(+), 23 deletions(-)
rename README-fr.md => README_fr-FR.md (84%)
diff --git a/README-fr.md b/README_fr-FR.md
similarity index 84%
rename from README-fr.md
rename to README_fr-FR.md
index 07406dfd..68a988a5 100644
--- a/README-fr.md
+++ b/README_fr-FR.md
@@ -36,9 +36,9 @@ sayHi();
#### Réponse: D
-Within the function, we first declare the `name` variable with the `var` keyword. This means that the variable gets hoisted (memory space is set up during the creation phase) with the default value of `undefined`, until we actually get to the line where we define the variable. We haven't defined the variable yet on the line where we try to log the `name` variable, so it still holds the value of `undefined`.
+Dans la fonction, nous déclarons en premier la variable `name` grâce au mot clé `var`. Cela signifie que la variable est "levée" _(hoisted)_ (l'espace mémoire est définie à la phase de création) avec pour valeur par défaut `undefined`, jusqu'à ce que le script atteigne la ligne de définition de la variable. Nous n'avons pas encore défini la variable lorsque nous essayons d'afficher la variable `name`, donc elle a toujours la valeur `undefined`.
-Variables with the `let` keyword (and `const`) are hoisted, but unlike `var`, don't get initialized. They are not accessible before the line we declare (initialize) them. This is called the "temporal dead zone". When we try to access the variables before they are declared, JavaScript throws a `ReferenceError`.
+Les variables avec le mot clé `let` (et `const`) sont "levées" _(hoisted)_, mais contrairement à `var`, elle n'est pas initialisée. Elles ne sont pas accessible avant la ligne qui les declare (initialise). C'est appelé la "zone morte temporaire". Lorsque nous essayons d'accéder aux variables avant leur déclaration, JavaScript renvoit une `ReferenceError`.
@@ -66,9 +66,9 @@ for (let i = 0; i < 3; i++) {
#### Réponse: C
-Because of the event queue in JavaScript, the `setTimeout` callback function is called _after_ the loop has been executed. Since the variable `i` in the first loop was declared using the `var` keyword, this value was global. During the loop, we incremented the value of `i` by `1` each time, using the unary operator `++`. By the time the `setTimeout` callback function was invoked, `i` was equal to `3` in the first example.
+À cause du système de queue dans JavaScript, la fonction de rappel _(callback)_ du `setTimeout` est appellée _après_ que la boucle soit exécutée. Comme la variable `i` dans la première boucle est déclarée avec le mot clé `var`, c'est une variable global. Pendant la boucle, nous incrémentons la valeur de `i` par `1` à chaque fois, en utilisant l'opérateur arithmétique `++`. Lorsque la fonction de rappel _(callback)_ du `setTimeout` est invoquée, `i` est égal à `3` dans le premier exemple.
-In the second loop, the variable `i` was declared using the `let` keyword: variables declared with the `let` (and `const`) keyword are block-scoped (a block is anything between `{ }`). During each iteration, `i` will have a new value, and each value is scoped inside the loop.
+Dans la seconde boucle, la variable `i` est déclarée avec le mot clé `let` : les variables déclarées avec `let` (et `const`) ont une portée de bloc (tout ce qui est entre `{ }` est considéré comme un bloc). Pendant chaque itération, `i` aura une nouvelle valeur, et chaque valeur sera définie dans la boucle.
@@ -100,11 +100,11 @@ shape.perimeter();
#### Réponse: B
-Note that the value of `diameter` is a regular function, whereas the value of `perimeter` is an arrow function.
+Notez que le valeur de `diameter` est une fonction régulière, alors que `perimeter` est une fonction fléchée.
-With arrow functions, the `this` keyword refers to its current surrounding scope, unlike regular functions! This means that when we call `perimeter`, it doesn't refer to the shape object, but to its surrounding scope (window for example).
+Avec les fonctions fléchée, le mot clé `this` réfère à son périmètre actuel, contrairement au fonctions régulières ! Cela signifie que lorsque nous appelons `perimeter`, elle ne réfère pas à l'objet shape, mais à son périmètre actuel (`window` par exemple).
-There is no value `radius` on that object, which returns `undefined`.
+Il n'y a pas de valeur `radius` dans cet objet, qui retournera `undefined`.
@@ -127,16 +127,16 @@ There is no value `radius` on that object, which returns `undefined`.
#### Réponse: A
-The unary plus tries to convert an operand to a number. `true` is `1`, and `false` is `0`.
+L'opérateur arithmétique `+` essait de convertir un opérande en une valeur numérique. `true` devient `1`, et `false` devient `0`.
-The string `'Lydia'` is a truthy value. What we're actually asking, is "is this truthy value falsy?". This returns `false`.
+La chaine de caractère `'Lydia'` est une value considérée comme vraie _(truthy)_. Ce que nous sommes actuellement entrain de demander, c'est "est-ce que cette valeur vraie est fausse ?". Ce qui retournera `false`.
---
-###### 5. Which one is true?
+###### 5. Laquelle est vraie ?
```javascript
const bird = {
@@ -159,13 +159,13 @@ const mouse = {
#### Réponse: A
-In JavaScript, all object keys are strings (unless it's a Symbol). Even though we might not _type_ them as strings, they are always converted into strings under the hood.
+En JavaScript, toutes les clé d'objet sont des chaines de caractères (sauf si c'est un Symbol). Bien que nous ne puission pas les _typer_ comme des chaines de caractères, elles sont converties en chaines de caractères sous le capot.
-JavaScript interprets (or unboxes) statements. When we use bracket notation, it sees the first opening bracket `[` and keeps going until it finds the closing bracket `]`. Only then, it will evaluate the statement.
+JavaScript interprète (ou décompresse) les instructions. Lorsque nous utilisons la notation pas crochet, il voit le premier crochet `[` et continue jusqu'à ce qu'il trouve le crochet fermant `]`. Seulement après, il évalue l'instruction.
-`mouse[bird.size]`: First it evaluates `bird.size`, which is `"small"`. `mouse["small"]` returns `true`
+`mouse[bird.size]` : Premièrement, il évalue `bird.size`, qui est `"small"`. `mouse["small"]` retourne `true`.
-However, with dot notation, this doesn't happen. `mouse` does not have a key called `bird`, which means that `mouse.bird` is `undefined`. Then, we ask for the `size` using dot notation: `mouse.bird.size`. Since `mouse.bird` is `undefined`, we're actually asking `undefined.size`. This isn't valid, and will throw an error similar to `Cannot read property "size" of undefined`.
+Cependant, avec la notation par points, cela n'arrive pas. `mouse` n'a pas de clé appelée `bird`, ce qui signifie que `mouse.bird` est `undefined`. Puis, on demande `size` en utilisant la notation par point : `mouse.bird.size`. Comme `mouse.bird` est `undefined`, on demande `undefined.size`. Cela n'est pas valide, et nous aurons une erreur similaire à `Impossible de lire la propriété "size" de undefined`.
@@ -196,13 +196,13 @@ console.log(d.greeting);
#### Réponse: A
-In JavaScript, all objects interact by _reference_ when setting them equal to each other.
+En JavaScript, tous les object intéragisent par _référence_ en plaçant égaux les uns aux autres.
-First, variable `c` holds a value to an object. Later, we assign `d` with the same reference that `c` has to the object.
+Premièrement, la variable `c` contaient une valeur d'objet. Plus tard, nous assignons `d` avec la même réference que `c` à l'objet.
-When you change one object, you change all of them.
+Quand on modifie un objet, on les modifie donc tous.
@@ -231,11 +231,11 @@ console.log(b === c);
#### Réponse: C
-`new Number()` is a built-in function constructor. Although it looks like a number, it's not really a number: it has a bunch of extra features and is an object.
+`new Number()` est une fonction globale. Bien qu'il ressamble à un nombre, ce n'en est pas vraiment un : il a une poignée de fonctionnalités supplémentaire and est un objet.
-When we use the `==` operator, it only checks whether it has the same _value_. They both have the value of `3`, so it returns `true`.
+Quand nous utilisons l'opérateur `==`, il vérifie seulement qu'il s'agisse de la même _valeur_. Les deux ont pour valeur `3`, donc il retourne `true`.
-However, when we use the `===` operator, both value _and_ type should be the same. It's not: `new Number()` is not a number, it's an **object**. Both return `false.`
+Cependant, quand on utilise l'opérateur `===`, les 2 valeurs _et_ type doivent être les même. `new Number()` n'est pas un nombre, c'est un **objet**, il retourne `false`.
@@ -270,7 +270,7 @@ freddie.colorChange("orange");
#### Réponse: D
-The `colorChange` function is static. Static methods are designed to live only on the constructor in which they are created, and cannot be passed down to any children. Since `freddie` is a child, the function is not passed down, and not available on the `freddie` instance: a `TypeError` is thrown.
+La fonction `colorChange` est statique. Les méthodes statiques sont désignée pour vivre seulement dans le constructeur qui les a créer et ne peuvent pas être transférer aux enfants. Comme `freddie` est un enfant, la fonction n'est pas transférée et non disponible dans l'instance de `freddie` : une erreur `TypeError` est renvoyée.
@@ -407,7 +407,7 @@ We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smit
---
-###### 13. What are the three phases of event propagation?
+###### 13. Quelle sont les trois phases de propagation des événements ?
- A: Target > Capturing > Bubbling
- B: Bubbling > Target > Capturing
@@ -419,7 +419,7 @@ We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smit
#### Réponse: D
-During the **capturing** phase, the event goes through the ancestor elements down to the target element. It then reaches the **target** element, and **bubbling** begins.
+Durant la phase de **capture** _(capturing)_, l'événement passe par les événements parent jusqu'à l'élément ciblé. Il attient ensuite l'élément **ciblé** _(target)_, et commence à **bouillonner** _(bubbling)_.
From b232c2170c31c3c5e65880a6c75031c95fe32b39 Mon Sep 17 00:00:00 2001
From: KL13NT
Date: Fri, 21 Jun 2019 01:06:19 +0200
Subject: [PATCH 031/881] Started Translation into Arabic
---
README_ar-EG.md | 1289 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 1289 insertions(+)
create mode 100644 README_ar-EG.md
diff --git a/README_ar-EG.md b/README_ar-EG.md
new file mode 100644
index 00000000..d41261ad
--- /dev/null
+++ b/README_ar-EG.md
@@ -0,0 +1,1289 @@
+# قائمة اسئلة جافاسكربت متقدمة
+أنا بنشر أسئلة اختر جافاسكربت كل يوم على [انستجرام](https://www.instagram.com/theavocoder) واللي بدوري هنشرهم هنا
+
+من البسيط للمتطور: اختبر نفسك في الجافاسكربت, افتكر حاجات كنت ناسيها, او جهز نفسك لمقابلة عمل جايه! :muscle: :rocket:
+
+الاجابات في الجزء المخفي تحت, ببساطة دوس على السؤال عشان تفتح تفاصيله. اتمنالكم حظ سعيد :heart:
+
+---
+
+###### 1. ايه اللي هيتطبع؟
+
+```javascript
+function sayHi() {
+ console.log(name);
+ console.log(age);
+ var name = "Lydia";
+ let age = 21;
+}
+
+sayHi();
+```
+
+- أ: `Lydia` و `undefined`
+- ب: `Lydia` و `ReferenceError`
+- ج: `ReferenceError` و `21`
+- د: `undefined` و `ReferenceError`
+
+Answer
+
+
+#### الاجابة الصحيحة: د
+
+جوا الدالة احنا الاول عملنا متغير `name` بالكلمة الدالة `var`. ده معناه ان المتغير ده هيكون موجود في الذاكرة في مرحلة التكوين بالقيمة `undefined` قبل ما الكود يشتغل لحد ما نوصل تحديداً للسطر اللي فيه بنحط قيمة للمتغير ده. احنا بقى لحد السطر اللي بنبطع فيه المتغير ده مكانش لسه اتعمل وبالتالي كان لسه فيه قيمة `undefined`.
+
+المتغيرات اللي بتتعمل بكلمة `let` و `const` بيعملوا نفس الموضوع, بس الفرق ان مبنقدرش ناخد قيم منهم الا لحد ما نضيفلهم قيم من الأساس. دي اسمها `temporal dead zone` او بالعربي "منطقة الموت المؤقتة". لما بنحاول ناخد قيمة متغير قبل ما نعمله جافاسكربت بترجع خطأ من نوع `ReferenceError`
+
+
+
+
+---
+
+###### 2. What's the output?
+
+```javascript
+for (var i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+
+for (let i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+```
+
+- A: `0 1 2` and `0 1 2`
+- B: `0 1 2` and `3 3 3`
+- C: `3 3 3` and `0 1 2`
+
+Answer
+
+
+#### Answer: C
+
+Because of the event queue in JavaScript, the `setTimeout` callback function is called _after_ the loop has been executed. Since the variable `i` in the first loop was declared using the `var` keyword, this value was global. During the loop, we incremented the value of `i` by `1` each time, using the unary operator `++`. By the time the `setTimeout` callback function was invoked, `i` was equal to `3` in the first example.
+
+In the second loop, the variable `i` was declared using the `let` keyword: variables declared with the `let` (and `const`) keyword are block-scoped (a block is anything between `{ }`). During each iteration, `i` will have a new value, and each value is scoped inside the loop.
+
+
+
+
+---
+
+###### 3. What's the output?
+
+```javascript
+const shape = {
+ radius: 10,
+ diameter() {
+ return this.radius * 2;
+ },
+ perimeter: () => 2 * Math.PI * this.radius
+};
+
+shape.diameter();
+shape.perimeter();
+```
+
+- A: `20` and `62.83185307179586`
+- B: `20` and `NaN`
+- C: `20` and `63`
+- D: `NaN` and `63`
+
+Answer
+
+
+#### Answer: B
+
+Note that the value of `diameter` is a regular function, whereas the value of `perimeter` is an arrow function.
+
+With arrow functions, the `this` keyword refers to its current surrounding scope, unlike regular functions! This means that when we call `perimeter`, it doesn't refer to the shape object, but to its surrounding scope (window for example).
+
+There is no value `radius` on that object, which returns `undefined`.
+
+
+
+
+---
+
+###### 4. What's the output?
+
+```javascript
++true;
+!"Lydia";
+```
+
+- A: `1` and `false`
+- B: `false` and `NaN`
+- C: `false` and `false`
+
+Answer
+
+
+#### Answer: A
+
+The unary plus tries to convert an operand to a number. `true` is `1`, and `false` is `0`.
+
+The string `'Lydia'` is a truthy value. What we're actually asking, is "is this truthy value falsy?". This returns `false`.
+
+
+
+
+---
+
+###### 5. Which one is true?
+
+```javascript
+const bird = {
+ size: "small"
+};
+
+const mouse = {
+ name: "Mickey",
+ small: true
+};
+```
+
+- A: `mouse.bird.size` is not valid
+- B: `mouse[bird.size]` is not valid
+- C: `mouse[bird["size"]]` is not valid
+- D: All of them are valid
+
+Answer
+
+
+#### Answer: A
+
+In JavaScript, all object keys are strings (unless it's a Symbol). Even though we might not _type_ them as strings, they are always converted into strings under the hood.
+
+JavaScript interprets (or unboxes) statements. When we use bracket notation, it sees the first opening bracket `[` and keeps going until it finds the closing bracket `]`. Only then, it will evaluate the statement.
+
+`mouse[bird.size]`: First it evaluates `bird.size`, which is `"small"`. `mouse["small"]` returns `true`
+
+However, with dot notation, this doesn't happen. `mouse` does not have a key called `bird`, which means that `mouse.bird` is `undefined`. Then, we ask for the `size` using dot notation: `mouse.bird.size`. Since `mouse.bird` is `undefined`, we're actually asking `undefined.size`. This isn't valid, and will throw an error similar to `Cannot read property "size" of undefined`.
+
+
+
+
+---
+
+---
+
+###### 6. What's the output?
+
+```javascript
+let c = { greeting: "Hey!" };
+let d;
+
+d = c;
+c.greeting = "Hello";
+console.log(d.greeting);
+```
+
+- A: `Hello`
+- B: `Hey`
+- C: `undefined`
+- D: `ReferenceError`
+- E: `TypeError`
+
+Answer
+
+
+#### Answer: A
+
+In JavaScript, all objects interact by _reference_ when setting them equal to each other.
+
+First, variable `c` holds a value to an object. Later, we assign `d` with the same reference that `c` has to the object.
+
+
+
+When you change one object, you change all of them.
+
+
+
+
+---
+
+###### 7. What's the output?
+
+```javascript
+let a = 3;
+let b = new Number(3);
+let c = 3;
+
+console.log(a == b);
+console.log(a === b);
+console.log(b === c);
+```
+
+- A: `true` `false` `true`
+- B: `false` `false` `true`
+- C: `true` `false` `false`
+- D: `false` `true` `true`
+
+Answer
+
+
+#### Answer: C
+
+`new Number()` is a built-in function constructor. Although it looks like a number, it's not really a number: it has a bunch of extra features and is an object.
+
+When we use the `==` operator, it only checks whether it has the same _value_. They both have the value of `3`, so it returns `true`.
+
+However, when we use the `===` operator, both value _and_ type should be the same. It's not: `new Number()` is not a number, it's an **object**. Both return `false.`
+
+
+
+
+---
+
+###### 8. What's the output?
+
+```javascript
+class Chameleon {
+ static colorChange(newColor) {
+ this.newColor = newColor;
+ return this.newColor;
+ }
+
+ constructor({ newColor = "green" } = {}) {
+ this.newColor = newColor;
+ }
+}
+
+const freddie = new Chameleon({ newColor: "purple" });
+freddie.colorChange("orange");
+```
+
+- A: `orange`
+- B: `purple`
+- C: `green`
+- D: `TypeError`
+
+Answer
+
+
+#### Answer: D
+
+The `colorChange` function is static. Static methods are designed to live only on the constructor in which they are created, and cannot be passed down to any children. Since `freddie` is a child, the function is not passed down, and not available on the `freddie` instance: a `TypeError` is thrown.
+
+
+
+
+---
+
+###### 9. What's the output?
+
+```javascript
+let greeting;
+greetign = {}; // Typo!
+console.log(greetign);
+```
+
+- A: `{}`
+- B: `ReferenceError: greetign is not defined`
+- C: `undefined`
+
+Answer
+
+
+#### Answer: A
+
+It logs the object, because we just created an empty object on the global object! When we mistyped `greeting` as `greetign`, the JS interpreter actually saw this as `global.greetign = {}` (or `window.greetign = {}` in a browser).
+
+In order to avoid this, we can use `"use strict"`. This makes sure that you have declared a variable before setting it equal to anything.
+
+
+
+
+---
+
+###### 10. What happens when we do this?
+
+```javascript
+function bark() {
+ console.log("Woof!");
+}
+
+bark.animal = "dog";
+```
+
+- A: Nothing, this is totally fine!
+- B: `SyntaxError`. You cannot add properties to a function this way.
+- C: `undefined`
+- D: `ReferenceError`
+
+Answer
+
+
+#### Answer: A
+
+This is possible in JavaScript, because functions are objects! (Everything besides primitive types are objects)
+
+A function is a special type of object. The code you write yourself isn't the actual function. The function is an object with properties. This property is invocable.
+
+
+
+
+---
+
+###### 11. What's the output?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const member = new Person("Lydia", "Hallie");
+Person.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+
+console.log(member.getFullName());
+```
+
+- A: `TypeError`
+- B: `SyntaxError`
+- C: `Lydia Hallie`
+- D: `undefined` `undefined`
+
+Answer
+
+
+#### Answer: A
+
+You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all objects at once, you have to use the prototype instead. So in this case,
+
+```js
+Person.prototype.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+```
+
+would have made `member.getFullName()` work. Why is this beneficial? Say that we added this method to the constructor itself. Maybe not every `Person` instance needed this method. This would waste a lot of memory space, since they would still have that property, which takes of memory space for each instance. Instead, if we only add it to the prototype, we just have it at one spot in memory, yet they all have access to it!
+
+
+
+
+---
+
+###### 12. What's the output?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const lydia = new Person("Lydia", "Hallie");
+const sarah = Person("Sarah", "Smith");
+
+console.log(lydia);
+console.log(sarah);
+```
+
+- A: `Person {firstName: "Lydia", lastName: "Hallie"}` and `undefined`
+- B: `Person {firstName: "Lydia", lastName: "Hallie"}` and `Person {firstName: "Sarah", lastName: "Smith"}`
+- C: `Person {firstName: "Lydia", lastName: "Hallie"}` and `{}`
+- D:`Person {firstName: "Lydia", lastName: "Hallie"}` and `ReferenceError`
+
+Answer
+
+
+#### Answer: A
+
+For `sarah`, we didn't use the `new` keyword. When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
+
+We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smith"`. What we actually did, is defining `global.firstName = 'Sarah'` and `global.lastName = 'Smith'`. `sarah` itself is left `undefined`.
+
+
+
+
+---
+
+###### 13. What are the three phases of event propagation?
+
+- A: Target > Capturing > Bubbling
+- B: Bubbling > Target > Capturing
+- C: Target > Bubbling > Capturing
+- D: Capturing > Target > Bubbling
+
+Answer
+
+
+#### Answer: D
+
+During the **capturing** phase, the event goes through the ancestor elements down to the target element. It then reaches the **target** element, and **bubbling** begins.
+
+
+
+
+
+
+---
+
+###### 14. All object have prototypes.
+
+- A: true
+- B: false
+
+Answer
+
+
+#### Answer: B
+
+All objects have prototypes, except for the **base object**. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
+
+
+
+
+---
+
+###### 15. What's the output?
+
+```javascript
+function sum(a, b) {
+ return a + b;
+}
+
+sum(1, "2");
+```
+
+- A: `NaN`
+- B: `TypeError`
+- C: `"12"`
+- D: `3`
+
+Answer
+
+
+#### Answer: C
+
+JavaScript is a **dynamically typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
+
+In this example, JavaScript converts the number `1` into a string, in order for the function to make sense and return a value. During the addition of a numeric type (`1`) and a string type (`'2'`), the number is treated as a string. We can concatenate strings like `"Hello" + "World"`, so what's happening here is `"1" + "2"` which returns `"12"`.
+
+
+
+
+---
+
+###### 16. What's the output?
+
+```javascript
+let number = 0;
+console.log(number++);
+console.log(++number);
+console.log(number);
+```
+
+- A: `1` `1` `2`
+- B: `1` `2` `2`
+- C: `0` `2` `2`
+- D: `0` `1` `2`
+
+Answer
+
+
+#### Answer: C
+
+The **postfix** unary operator `++`:
+
+1. Returns the value (this returns `0`)
+2. Increments the value (number is now `1`)
+
+The **prefix** unary operator `++`:
+
+1. Increments the value (number is now `2`)
+2. Returns the value (this returns `2`)
+
+This returns `0 2 2`.
+
+
+
+
+---
+
+###### 17. What's the output?
+
+```javascript
+function getPersonInfo(one, two, three) {
+ console.log(one);
+ console.log(two);
+ console.log(three);
+}
+
+const person = "Lydia";
+const age = 21;
+
+getPersonInfo`${person} is ${age} years old`;
+```
+
+- A: `"Lydia"` `21` `["", " is ", " years old"]`
+- B: `["", " is ", " years old"]` `"Lydia"` `21`
+- C: `"Lydia"` `["", " is ", " years old"]` `21`
+
+Answer
+
+
+#### Answer: B
+
+If you use tagged template literals, the value of the first argument is always an array of the string values. The remaining arguments get the values of the passed expressions!
+
+
+
+
+---
+
+###### 18. What's the output?
+
+```javascript
+function checkAge(data) {
+ if (data === { age: 18 }) {
+ console.log("You are an adult!");
+ } else if (data == { age: 18 }) {
+ console.log("You are still an adult.");
+ } else {
+ console.log(`Hmm.. You don't have an age I guess`);
+ }
+}
+
+checkAge({ age: 18 });
+```
+
+- A: `You are an adult!`
+- B: `You are still an adult.`
+- C: `Hmm.. You don't have an age I guess`
+
+Answer
+
+
+#### Answer: C
+
+When testing equality, primitives are compared by their _value_, while objects are compared by their _reference_. JavaScript checks if the objects have a reference to the same location in memory.
+
+The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
+
+This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }` return `false`.
+
+
+
+
+---
+
+###### 19. What's the output?
+
+```javascript
+function getAge(...args) {
+ console.log(typeof args);
+}
+
+getAge(21);
+```
+
+- A: `"number"`
+- B: `"array"`
+- C: `"object"`
+- D: `"NaN"`
+
+Answer
+
+
+#### Answer: C
+
+The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
+
+
+
+
+---
+
+###### 20. What's the output?
+
+```javascript
+function getAge() {
+ "use strict";
+ age = 21;
+ console.log(age);
+}
+
+getAge();
+```
+
+- A: `21`
+- B: `undefined`
+- C: `ReferenceError`
+- D: `TypeError`
+
+Answer
+
+
+#### Answer: C
+
+With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. If we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
+
+
+
+
+---
+
+###### 21. What's value of `sum`?
+
+```javascript
+const sum = eval("10*10+5");
+```
+
+- A: `105`
+- B: `"105"`
+- C: `TypeError`
+- D: `"10*10+5"`
+
+Answer
+
+
+#### Answer: A
+
+`eval` evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is `10 * 10 + 5`. This returns the number `105`.
+
+
+
+
+---
+
+###### 22. How long is cool_secret accessible?
+
+```javascript
+sessionStorage.setItem("cool_secret", 123);
+```
+
+- A: Forever, the data doesn't get lost.
+- B: When the user closes the tab.
+- C: When the user closes the entire browser, not only the tab.
+- D: When the user shuts off their computer.
+
+Answer
+
+
+#### Answer: B
+
+The data stored in `sessionStorage` is removed after closing the _tab_.
+
+If you used `localStorage`, the data would've been there forever, unless for example `localStorage.clear()` is invoked.
+
+
+
+
+---
+
+###### 23. What's the output?
+
+```javascript
+var num = 8;
+var num = 10;
+
+console.log(num);
+```
+
+- A: `8`
+- B: `10`
+- C: `SyntaxError`
+- D: `ReferenceError`
+
+Answer
+
+
+#### Answer: B
+
+With the `var` keyword, you can declare multiple variables with the same name. The variable will then hold the latest value.
+
+You cannot do this with `let` or `const` since they're block-scoped.
+
+
+
+
+---
+
+###### 24. What's the output?
+
+```javascript
+const obj = { 1: "a", 2: "b", 3: "c" };
+const set = new Set([1, 2, 3, 4, 5]);
+
+obj.hasOwnProperty("1");
+obj.hasOwnProperty(1);
+set.has("1");
+set.has(1);
+```
+
+- A: `false` `true` `false` `true`
+- B: `false` `true` `true` `true`
+- C: `true` `true` `false` `true`
+- D: `true` `true` `true` `true`
+
+Answer
+
+
+#### Answer: C
+
+All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
+
+It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')` returns `false`. It has the numeric type `1`, `set.has(1)` returns `true`.
+
+
+
+
+---
+
+###### 25. What's the output?
+
+```javascript
+const obj = { a: "one", b: "two", a: "three" };
+console.log(obj);
+```
+
+- A: `{ a: "one", b: "two" }`
+- B: `{ b: "two", a: "three" }`
+- C: `{ a: "three", b: "two" }`
+- D: `SyntaxError`
+
+Answer
+
+
+#### Answer: C
+
+If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
+
+
+
+
+---
+
+###### 26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
+
+- A: true
+- B: false
+- C: it depends
+
+Answer
+
+
+#### Answer: A
+
+The base execution context is the global execution context: it's what's accessible everywhere in your code.
+
+
+
+
+---
+
+###### 27. What's the output?
+
+```javascript
+for (let i = 1; i < 5; i++) {
+ if (i === 3) continue;
+ console.log(i);
+}
+```
+
+- A: `1` `2`
+- B: `1` `2` `3`
+- C: `1` `2` `4`
+- D: `1` `3` `4`
+
+Answer
+
+
+#### Answer: C
+
+The `continue` statement skips an iteration if a certain condition returns `true`.
+
+
+
+
+---
+
+###### 28. What's the output?
+
+```javascript
+String.prototype.giveLydiaPizza = () => {
+ return "Just give Lydia pizza already!";
+};
+
+const name = "Lydia";
+
+name.giveLydiaPizza();
+```
+
+- A: `"Just give Lydia pizza already!"`
+- B: `TypeError: not a function`
+- C: `SyntaxError`
+- D: `undefined`
+
+Answer
+
+
+#### Answer: A
+
+`String` is a built-in constructor, which we can add properties to. I just added a method to its prototype. Primitive strings are automatically converted into a string object, generated by the string prototype function. So, all strings (string objects) have access to that method!
+
+
+
+
+---
+
+###### 29. What's the output?
+
+```javascript
+const a = {};
+const b = { key: "b" };
+const c = { key: "c" };
+
+a[b] = 123;
+a[c] = 456;
+
+console.log(a[b]);
+```
+
+- A: `123`
+- B: `456`
+- C: `undefined`
+- D: `ReferenceError`
+
+Answer
+
+
+#### Answer: B
+
+Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`.
+
+However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
+
+Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to `456`, so it returns `456`.
+
+
+
+
+---
+
+###### 30. What's the output?
+
+```javascript
+const foo = () => console.log("First");
+const bar = () => setTimeout(() => console.log("Second"));
+const baz = () => console.log("Third");
+
+bar();
+foo();
+baz();
+```
+
+- A: `First` `Second` `Third`
+- B: `First` `Third` `Second`
+- C: `Second` `First` `Third`
+- D: `Second` `Third` `First`
+
+Answer
+
+
+#### Answer: B
+
+We have a `setTimeout` function and invoked it first. Yet, it was logged last.
+
+This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
+
+After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
+
+
+
+Now, `foo` gets invoked, and `"First"` is being logged.
+
+
+
+`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged.
+
+
+
+The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_.
+
+
+
+This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
+
+
+
+`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack.
+
+
+
+
+---
+
+###### 31. What is the event.target when clicking the button?
+
+```html
+
+```
+
+- A: Outer `div`
+- B: Inner `div`
+- C: `button`
+- D: An array of all nested elements.
+
+Answer
+
+
+#### Answer: C
+
+The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+
+
+
+
+---
+
+###### 32. When you click the paragraph, what's the logged output?
+
+```html
+
+```
+
+- A: `p` `div`
+- B: `div` `p`
+- C: `p`
+- D: `div`
+
+Answer
+
+
+#### Answer: A
+
+If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
+
+
+
+
+---
+
+###### 33. What's the output?
+
+```javascript
+const person = { name: "Lydia" };
+
+function sayHi(age) {
+ console.log(`${this.name} is ${age}`);
+}
+
+sayHi.call(person, 21);
+sayHi.bind(person, 21);
+```
+
+- A: `undefined is 21` `Lydia is 21`
+- B: `function` `function`
+- C: `Lydia is 21` `Lydia is 21`
+- D: `Lydia is 21` `function`
+
+Answer
+
+
+#### Answer: D
+
+With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
+
+`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
+
+
+
+
+---
+
+###### 34. What's the output?
+
+```javascript
+function sayHi() {
+ return (() => 0)();
+}
+
+typeof sayHi();
+```
+
+- A: `"object"`
+- B: `"number"`
+- C: `"function"`
+- D: `"undefined"`
+
+Answer
+
+
+#### Answer: B
+
+The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+
+FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+
+
+
+
+---
+
+###### 35. Which of these values are falsy?
+
+```javascript
+0;
+new Number(0);
+("");
+(" ");
+new Boolean(false);
+undefined;
+```
+
+- A: `0`, `''`, `undefined`
+- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
+- C: `0`, `''`, `new Boolean(false)`, `undefined`
+- D: All of them are falsy
+
+Answer
+
+
+#### Answer: A
+
+There are only six falsy values:
+
+- `undefined`
+- `null`
+- `NaN`
+- `0`
+- `''` (empty string)
+- `false`
+
+Function constructors, like `new Number` and `new Boolean` are truthy.
+
+
+
+
+---
+
+###### 36. What's the output?
+
+```javascript
+console.log(typeof typeof 1);
+```
+
+- A: `"number"`
+- B: `"string"`
+- C: `"object"`
+- D: `"undefined"`
+
+Answer
+
+
+#### Answer: B
+
+`typeof 1` returns `"number"`.
+`typeof "number"` returns `"string"`
+
+
+
+
+---
+
+###### 37. What's the output?
+
+```javascript
+const numbers = [1, 2, 3];
+numbers[10] = 11;
+console.log(numbers);
+```
+
+- A: `[1, 2, 3, 7 x null, 11]`
+- B: `[1, 2, 3, 11]`
+- C: `[1, 2, 3, 7 x empty, 11]`
+- D: `SyntaxError`
+
+Answer
+
+
+#### Answer: C
+
+When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like:
+
+`[1, 2, 3, 7 x empty, 11]`
+
+depending on where you run it (it's different for every browser, node, etc.)
+
+
+
+
+---
+
+###### 38. What's the output?
+
+```javascript
+(() => {
+ let x, y;
+ try {
+ throw new Error();
+ } catch (x) {
+ (x = 1), (y = 2);
+ console.log(x);
+ }
+ console.log(x);
+ console.log(y);
+})();
+```
+
+- A: `1` `undefined` `2`
+- B: `undefined` `undefined` `undefined`
+- C: `1` `1` `2`
+- D: `1` `undefined` `undefined`
+
+Answer
+
+
+#### Answer: A
+
+The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
+
+Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+
+Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+
+
+
+
+---
+
+###### 39. Everything in JavaScript is either a...
+
+- A: primitive or object
+- B: function or object
+- C: trick question! only objects
+- D: number or object
+
+Answer
+
+
+#### Answer: A
+
+JavaScript only has primitive types and objects.
+
+Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+
+What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+
+
+
+
+---
+
+###### 40. What's the output?
+
+```javascript
+[[0, 1], [2, 3]].reduce(
+ (acc, cur) => {
+ return acc.concat(cur);
+ },
+ [1, 2]
+);
+```
+
+- A: `[0, 1, 2, 3, 1, 2]`
+- B: `[6, 1, 2]`
+- C: `[1, 2, 0, 1, 2, 3]`
+- D: `[1, 2, 6]`
+
+Answer
+
+
+#### Answer: C
+
+`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
+
+Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
+
+
+
+
+---
+
+###### 41. What's the output?
+
+```javascript
+!!null;
+!!"";
+!!1;
+```
+
+- A: `false` `true` `false`
+- B: `false` `false` `true`
+- C: `false` `true` `true`
+- D: `true` `true` `false`
+
+Answer
+
+
+#### Answer: B
+
+`null` is falsy. `!null` returns `true`. `!true` returns `false`.
+
+`""` is falsy. `!""` returns `true`. `!true` returns `false`.
+
+`1` is truthy. `!1` returns `false`. `!false` returns `true`.
+
+
+
+
+---
+
+###### 42. What does the `setInterval` method return in the browser?
+
+```javascript
+setInterval(() => console.log("Hi"), 1000);
+```
+
+- A: a unique id
+- B: the amount of milliseconds specified
+- C: the passed function
+- D: `undefined`
+
+Answer
+
+
+#### Answer: A
+
+It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function.
+
+
+
+
+---
+
+###### 43. What does this return?
+
+```javascript
+[..."Lydia"];
+```
+
+- A: `["L", "y", "d", "i", "a"]`
+- B: `["Lydia"]`
+- C: `[[], "Lydia"]`
+- D: `[["L", "y", "d", "i", "a"]]`
+
+Answer
+
+
+#### Answer: A
+
+A string is an iterable. The spread operator maps every character of an iterable to one element.
+
+
+
From 3746909e740b01ead952e21e70501abcd1020016 Mon Sep 17 00:00:00 2001
From: KL13NT
Date: Fri, 21 Jun 2019 01:24:16 +0200
Subject: [PATCH 032/881] Started Translation into Arabic
---
README_ar-EG.md | 39 +++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/README_ar-EG.md b/README_ar-EG.md
index d41261ad..2446fd5c 100644
--- a/README_ar-EG.md
+++ b/README_ar-EG.md
@@ -1,4 +1,4 @@
-# قائمة اسئلة جافاسكربت متقدمة
+# قائمة اسئلة جافاسكربت متقدمة
أنا بنشر أسئلة اختر جافاسكربت كل يوم على [انستجرام](https://www.instagram.com/theavocoder) واللي بدوري هنشرهم هنا
من البسيط للمتطور: اختبر نفسك في الجافاسكربت, افتكر حاجات كنت ناسيها, او جهز نفسك لمقابلة عمل جايه! :muscle: :rocket:
@@ -39,7 +39,7 @@ sayHi();
---
-###### 2. What's the output?
+###### 2. ايه اللي هيتطبع؟
```javascript
for (var i = 0; i < 3; i++) {
@@ -51,25 +51,25 @@ for (let i = 0; i < 3; i++) {
}
```
-- A: `0 1 2` and `0 1 2`
-- B: `0 1 2` and `3 3 3`
-- C: `3 3 3` and `0 1 2`
+أ- `0 1 2` و `0 1 2`
+ب- `0 1 2` و `3 3 3`
+ج- `3 3 3` و `0 1 2`
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة: ج
-Because of the event queue in JavaScript, the `setTimeout` callback function is called _after_ the loop has been executed. Since the variable `i` in the first loop was declared using the `var` keyword, this value was global. During the loop, we incremented the value of `i` by `1` each time, using the unary operator `++`. By the time the `setTimeout` callback function was invoked, `i` was equal to `3` in the first example.
+الفنكشن اللي`setTimeout` بتشغلها بيتم تشغليها _بعد_ ما اللووب تخلص بسبب قائمة الاحداث `event queue` في جافاسكربت. بما ان اول لووب اتعملت كان المتغير بتاعها معمول بكلمة `var` اذا كان `global` وبالتالي في اللوب احنا كل شوية كنا بنزود `i` لحد ما وصل ل 3 و _بعد_ كده قامت الفنكشن اللي جوا `setTimeout` اشتغلت. ده كده اول لووب.
-In the second loop, the variable `i` was declared using the `let` keyword: variables declared with the `let` (and `const`) keyword are block-scoped (a block is anything between `{ }`). During each iteration, `i` will have a new value, and each value is scoped inside the loop.
+اما بقى في تاني لووب المتغير `i` كان معمول بكلمة `let` و بالتالي المنظور بتاعه `scope` محدد بالاقواس المحيطة بيه `block` وبالتالي في كل مره اللوب هتزيد هيكون في قيمة جديدة تماماً للمتغير `i` و كل قيمة من دول موجوده جوا ال`block scope` اللي هي حصلت فيه, و بالتالي هيبقى كأن البرنامج شايف 3 قيم للمتغير `i` في 3 اماكن مختلفه!
---
-###### 3. What's the output?
+###### 3. ايه اللي هيتطبع؟
```javascript
const shape = {
@@ -84,22 +84,21 @@ shape.diameter();
shape.perimeter();
```
-- A: `20` and `62.83185307179586`
-- B: `20` and `NaN`
-- C: `20` and `63`
-- D: `NaN` and `63`
+أ- `20` و `62.83185307179586`
+ب- `20` و `NaN`
+ج- `20` و `63`
+د- `NaN` و `63`
-Answer
+الاجابة
-#### Answer: B
-
-Note that the value of `diameter` is a regular function, whereas the value of `perimeter` is an arrow function.
+#### الاجابة: ب
-With arrow functions, the `this` keyword refers to its current surrounding scope, unlike regular functions! This means that when we call `perimeter`, it doesn't refer to the shape object, but to its surrounding scope (window for example).
+خلي بالك من نوعية الفنكشن `diameter` و هي `regular`و نوعية الفنكشن `perimeter` واللي هي `arrow function`.
-There is no value `radius` on that object, which returns `undefined`.
+في النوع الاخير, الكلمة الدالة `this` بتشاور الى المحيط بالدالة دي. وده معناه اننا لما بنشغل `perimeter` احنا مش بنشاور ب`this` على `shape` بل بنشاور على المحيط و هو `window` مثلاً!
+وبالتالي مفيش قيمة `radius` في النطاق ده, و بالتالي البرنامج بيدينا `undefined`.
From f73cc4ff423e7250b3eacd1b0b69af1e9aaa5716 Mon Sep 17 00:00:00 2001
From: KL13NT
Date: Fri, 21 Jun 2019 01:25:55 +0200
Subject: [PATCH 033/881] Finished q.3
---
README_ar-EG.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/README_ar-EG.md b/README_ar-EG.md
index 2446fd5c..979309ab 100644
--- a/README_ar-EG.md
+++ b/README_ar-EG.md
@@ -51,9 +51,9 @@ for (let i = 0; i < 3; i++) {
}
```
-أ- `0 1 2` و `0 1 2`
-ب- `0 1 2` و `3 3 3`
-ج- `3 3 3` و `0 1 2`
+أ - `0 1 2` و `0 1 2`
+ب - `0 1 2` و `3 3 3`
+ج - `3 3 3` و `0 1 2`
الاجابة
@@ -84,10 +84,10 @@ shape.diameter();
shape.perimeter();
```
-أ- `20` و `62.83185307179586`
-ب- `20` و `NaN`
-ج- `20` و `63`
-د- `NaN` و `63`
+أ - `20` و `62.83185307179586`
+ب - `20` و `NaN`
+ج - `20` و `63`
+د - `NaN` و `63`
الاجابة
From d3ad3f4da7c4e5b1d4158e9a4c7e89d69dc13c8b Mon Sep 17 00:00:00 2001
From: KL13NT
Date: Fri, 21 Jun 2019 01:28:10 +0200
Subject: [PATCH 034/881] Finished q.3
---
README_ar-EG.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/README_ar-EG.md b/README_ar-EG.md
index 979309ab..d935b106 100644
--- a/README_ar-EG.md
+++ b/README_ar-EG.md
@@ -51,9 +51,9 @@ for (let i = 0; i < 3; i++) {
}
```
-أ - `0 1 2` و `0 1 2`
-ب - `0 1 2` و `3 3 3`
-ج - `3 3 3` و `0 1 2`
+- أ: `0 1 2` و `0 1 2`
+- ب: `0 1 2` و `3 3 3`
+- ج: `3 3 3` و `0 1 2`
الاجابة
@@ -84,10 +84,10 @@ shape.diameter();
shape.perimeter();
```
-أ - `20` و `62.83185307179586`
-ب - `20` و `NaN`
-ج - `20` و `63`
-د - `NaN` و `63`
+- أ: `20` و `62.83185307179586`
+- ب: `20` و `NaN`
+- ج: `20` و `63`
+- د: `NaN` و `63`
الاجابة
From 90164f7e3199614c1810a00c16ad28351ee892c4 Mon Sep 17 00:00:00 2001
From: Nabil Tharwat
Date: Fri, 21 Jun 2019 01:39:47 +0200
Subject: [PATCH 035/881] Update README_ar-EG.md
---
README_ar-EG.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/README_ar-EG.md b/README_ar-EG.md
index d935b106..6f8b6fdb 100644
--- a/README_ar-EG.md
+++ b/README_ar-EG.md
@@ -1,4 +1,5 @@
-# قائمة اسئلة جافاسكربت متقدمة
+
+# قائمة اسئلة جافاسكربت متقدمة
أنا بنشر أسئلة اختر جافاسكربت كل يوم على [انستجرام](https://www.instagram.com/theavocoder) واللي بدوري هنشرهم هنا
من البسيط للمتطور: اختبر نفسك في الجافاسكربت, افتكر حاجات كنت ناسيها, او جهز نفسك لمقابلة عمل جايه! :muscle: :rocket:
@@ -1286,3 +1287,4 @@ A string is an iterable. The spread operator maps every character of an iterable
+
From 8ad8f98536c4b5e8f3e35a9d844e1c558c8ac7a6 Mon Sep 17 00:00:00 2001
From: Nabil Tharwat
Date: Fri, 21 Jun 2019 01:40:41 +0200
Subject: [PATCH 036/881] Update README_ar-EG.md
---
README_ar-EG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README_ar-EG.md b/README_ar-EG.md
index 6f8b6fdb..a99688d3 100644
--- a/README_ar-EG.md
+++ b/README_ar-EG.md
@@ -1,4 +1,5 @@
+
# قائمة اسئلة جافاسكربت متقدمة
أنا بنشر أسئلة اختر جافاسكربت كل يوم على [انستجرام](https://www.instagram.com/theavocoder) واللي بدوري هنشرهم هنا
From 2afd42531b25818b9aae826bb9cac0af7b189b06 Mon Sep 17 00:00:00 2001
From: Nabil Tharwat
Date: Fri, 21 Jun 2019 01:41:38 +0200
Subject: [PATCH 037/881] Update README_ar-EG.md
---
README_ar-EG.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/README_ar-EG.md b/README_ar-EG.md
index a99688d3..b1a61513 100644
--- a/README_ar-EG.md
+++ b/README_ar-EG.md
@@ -11,6 +11,8 @@
###### 1. ايه اللي هيتطبع؟
+
+
```javascript
function sayHi() {
console.log(name);
@@ -21,6 +23,7 @@ function sayHi() {
sayHi();
```
+
- أ: `Lydia` و `undefined`
- ب: `Lydia` و `ReferenceError`
From d503913c407301929656090f2423599f5d645dab Mon Sep 17 00:00:00 2001
From: Nabil Tharwat
Date: Fri, 21 Jun 2019 01:42:30 +0200
Subject: [PATCH 038/881] Update README_ar-EG.md
---
README_ar-EG.md | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/README_ar-EG.md b/README_ar-EG.md
index b1a61513..ae7814e5 100644
--- a/README_ar-EG.md
+++ b/README_ar-EG.md
@@ -45,7 +45,8 @@ sayHi();
---
###### 2. ايه اللي هيتطبع؟
-
+
+
```javascript
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 1);
@@ -55,6 +56,7 @@ for (let i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 1);
}
```
+
- أ: `0 1 2` و `0 1 2`
- ب: `0 1 2` و `3 3 3`
@@ -75,7 +77,8 @@ for (let i = 0; i < 3; i++) {
---
###### 3. ايه اللي هيتطبع؟
-
+
+
```javascript
const shape = {
radius: 10,
@@ -88,6 +91,7 @@ const shape = {
shape.diameter();
shape.perimeter();
```
+
- أ: `20` و `62.83185307179586`
- ب: `20` و `NaN`
From e0e96047e8b02d54110045fe8a0179c65e28361c Mon Sep 17 00:00:00 2001
From: Nabil Tharwat
Date: Fri, 21 Jun 2019 01:44:03 +0200
Subject: [PATCH 039/881] Update README_ar-EG.md
---
README_ar-EG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_ar-EG.md b/README_ar-EG.md
index ae7814e5..54c0f44f 100644
--- a/README_ar-EG.md
+++ b/README_ar-EG.md
@@ -67,7 +67,7 @@ for (let i = 0; i < 3; i++) {
#### الاجابة: ج
-الفنكشن اللي`setTimeout` بتشغلها بيتم تشغليها _بعد_ ما اللووب تخلص بسبب قائمة الاحداث `event queue` في جافاسكربت. بما ان اول لووب اتعملت كان المتغير بتاعها معمول بكلمة `var` اذا كان `global` وبالتالي في اللوب احنا كل شوية كنا بنزود `i` لحد ما وصل ل 3 و _بعد_ كده قامت الفنكشن اللي جوا `setTimeout` اشتغلت. ده كده اول لووب.
+الفنكشن اللي`setTimeout` بتشغلها بيتم تشغليها _بعد_ ما اللووب تخلص بسبب قائمة الاحداث `event queue` في جافاسكربت. بما ان اول لووب اتعملت كان المتغير بتاعها معمول بكلمة `var` اذاً كان `global` وبالتالي في اللوب احنا كل شوية كنا بنزود `i` لحد ما وصل ل 3 و _بعد_ كده قامت الفنكشن اللي جوا `setTimeout` اشتغلت. ده كده اول لووب.
اما بقى في تاني لووب المتغير `i` كان معمول بكلمة `let` و بالتالي المنظور بتاعه `scope` محدد بالاقواس المحيطة بيه `block` وبالتالي في كل مره اللوب هتزيد هيكون في قيمة جديدة تماماً للمتغير `i` و كل قيمة من دول موجوده جوا ال`block scope` اللي هي حصلت فيه, و بالتالي هيبقى كأن البرنامج شايف 3 قيم للمتغير `i` في 3 اماكن مختلفه!
From 856af98f4ffc988f963b71168a7bd7bb7d9b22f8 Mon Sep 17 00:00:00 2001
From: synccheng
Date: Fri, 21 Jun 2019 11:31:37 +0800
Subject: [PATCH 040/881] :memo: Translate & Typo
---
README-zh_CN.md | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/README-zh_CN.md b/README-zh_CN.md
index bc21b456..91bc8fdf 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -308,8 +308,8 @@ function bark() {
bark.animal = 'dog'
```
-- A: Nothing, this is totally fine!
-- B: `SyntaxError`. You cannot add properties to a function this way.
+- A: 正常运行!
+- B: `SyntaxError`. 你不能通过这种方式给函数增加属性。
- C: `undefined`
- D: `ReferenceError`
@@ -657,10 +657,10 @@ const sum = eval('10*10+5')
sessionStorage.setItem('cool_secret', 123)
```
-- A: Forever, the data doesn't get lost.
-- B: When the user closes the tab.
-- C: When the user closes the entire browser, not only the tab.
-- D: When the user shuts off their computer.
+- A: 永远,数据不会丢失。
+- B: 当用户关掉标签页时。
+- C: 当用户关掉整个浏览器,而不只是关掉标签页。
+- D: 当用户关闭电脑时。
答案
@@ -857,9 +857,9 @@ console.log(a[b])
对象的键被自动转换为字符串。我们试图将一个对象 `b` 设置为对象 `a` 的键,且相应的值为 `123`。
-然而,当字符串化一个对象时,它会变成 `"[Object object]"`。因此这里说的是,`a["Object object"] = 123`。然后,我们再一次做了同样的事情,`c` 是另外一个对象,这里也有隐式字符串化,于是,`a["Object object"] = 456`。
+然而,当字符串化一个对象时,它会变成 `"[object Object]"`。因此这里说的是,`a["[object Object]"] = 123`。然后,我们再一次做了同样的事情,`c` 是另外一个对象,这里也有隐式字符串化,于是,`a["[object Object]"] = 456`。
-然后,我们打印 `a[b]`,也就是 `a["Object object"]`。之前刚设置为 `456`,因此返回的是 `456`。
+然后,我们打印 `a[b]`,也就是 `a["[object Object]"]`。之前刚设置为 `456`,因此返回的是 `456`。
@@ -934,7 +934,7 @@ WebAPI 不能随时向栈内添加内容。相反,它将回调函数推到名
- A: Outer `div`
- B: Inner `div`
- C: `button`
-- D: An array of all nested elements.
+- D: 一个包含所有嵌套元素的数组。
答案
@@ -1167,10 +1167,10 @@ console.log(numbers)
###### 39. JavaScript 中的一切都是?
-- A: primitive or object
-- B: function or object
-- C: trick question! only objects
-- D: number or object
+- A: 基本类型与对象
+- B: 函数与对象
+- C: 只有对象
+- D: 数字与对象
-
答案
@@ -1250,9 +1250,9 @@ JavaScript 只有基本类型和对象。
setInterval(() => console.log('Hi'), 1000)
```
-- A: a unique id
-- B: the amount of milliseconds specified
-- C: the passed function
+- A: 一个唯一的id
+- B: 该方法指定的毫秒数
+- C: 传递的函数
- D: `undefined`
答案
From d9d846c13028eb84f65e6c884d9942cac734d361 Mon Sep 17 00:00:00 2001
From: re4388
Date: Fri, 21 Jun 2019 14:22:19 +0800
Subject: [PATCH 041/881] delete extra separate line in README.md
---
README.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README.md b/README.md
index 916fa133..3d058815 100644
--- a/README.md
+++ b/README.md
@@ -174,7 +174,6 @@ However, with dot notation, this doesn't happen. `mouse` does not have a key cal
---
----
###### 6. What's the output?
From 0a702c130a45083d5391f87a0dc774d0749d763b Mon Sep 17 00:00:00 2001
From: re4388
Date: Fri, 21 Jun 2019 14:32:42 +0800
Subject: [PATCH 042/881] Remove extra separate line in README-zh_CN.md
---
README-zh_CN.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README-zh_CN.md b/README-zh_CN.md
index bc21b456..06f8f9e2 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -168,7 +168,6 @@ const mouse = {
---
----
###### 6. 输出是什么?
From 1a4aeb46b82e023d11d272c5793bb4eaceef1298 Mon Sep 17 00:00:00 2001
From: re4388
Date: Fri, 21 Jun 2019 14:36:46 +0800
Subject: [PATCH 043/881] Remove extra separate line
---
README-bs_BS.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README-bs_BS.md b/README-bs_BS.md
index 75e47080..57306554 100644
--- a/README-bs_BS.md
+++ b/README-bs_BS.md
@@ -215,7 +215,6 @@ To nije valjano, a bit će u pitanju pogreška slična onoj
* * * * *
-* * * * *
###### 6. Što je izlaz?
From f0ede076b75c32fc0f7daed8d0fa0f23bb3e38e5 Mon Sep 17 00:00:00 2001
From: re4388
Date: Fri, 21 Jun 2019 14:37:15 +0800
Subject: [PATCH 044/881] Remove extra separate line
---
README-de_DE.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README-de_DE.md b/README-de_DE.md
index cefffd01..47d99e8d 100644
--- a/README-de_DE.md
+++ b/README-de_DE.md
@@ -172,7 +172,6 @@ Mit der Dot Notation ist das nicht der Fall. `mouse` hat keinen Key namens `bird
---
----
###### 6. Was ist der Output?
From f8d8614b803a19a63fbb856aa7363187a4d7a7eb Mon Sep 17 00:00:00 2001
From: re4388
Date: Fri, 21 Jun 2019 14:37:40 +0800
Subject: [PATCH 045/881] Remove extra separate line
---
README-vi.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README-vi.md b/README-vi.md
index b9b7c3be..0fcd67cd 100644
--- a/README-vi.md
+++ b/README-vi.md
@@ -169,7 +169,6 @@ Tuy nhiên, khi chúng ta sử dụng dấu chấm `.`, điều trên không cò
---
----
###### 6. Ouput là gì?
From bbe4cab0fb870b2a53dc6c0fa938d48f8026156e Mon Sep 17 00:00:00 2001
From: re4388
Date: Fri, 21 Jun 2019 14:38:12 +0800
Subject: [PATCH 046/881] Remove extra separate line
---
README_ru-RU.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index b8e918df..38cd0efb 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -174,7 +174,6 @@ JavaScript интерпретирует (или распаковывает) оп
---
----
###### 6. Что будет в консоли?
From e43b5adf9f0f472304949e95ca1d3870656f0cdd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n?= <22575055+aguadotzn@users.noreply.github.com>
Date: Fri, 21 Jun 2019 10:52:14 +0200
Subject: [PATCH 047/881] Questions 30-42
---
README-ES.md | 147 ++++++++++++++++++++++++++-------------------------
1 file changed, 74 insertions(+), 73 deletions(-)
diff --git a/README-ES.md b/README-ES.md
index 96b2c57c..9f28798d 100644
--- a/README-ES.md
+++ b/README-ES.md
@@ -915,14 +915,14 @@ Aquí es donde un bucle de eventos comienza a funcionar. Un **lazo de evento** m
-Se invoca el `bar`, se registra el ``"Second"`` y se quita de la pila.
+Se invoca el `bar`, se registra el `"Second"` y se quita de la pila.
---
-###### 31. What is the event.target when clicking the button?
+###### 31. ¿Cuál es la referencia al objeto que lanza el evento cuando se hace click en el botón?
```html
@@ -939,19 +939,19 @@ Se invoca el `bar`, se registra el ``"Second"`` y se quita de la pila.
- C: `button`
- D: An array of all nested elements.
-
Answer
+Solución
-#### Answer: C
+#### Respuesta correcta: C
-The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+El elemento anidado más profundo que causa el evento es el destino de ese evento.
---
-###### 32. When you click the paragraph, what's the logged output?
+###### 32. Al hacer click en el párrafo, ¿qué se muestra por pantalla?
```html
@@ -966,19 +966,19 @@ The deepest nested element that caused the event is the target of the event. You
- C: `p`
- D: `div`
-
Answer
+Solución
-#### Answer: A
+#### Respuesta correcta: A
-If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
+Si hacemos clic en `p`, vemos dos _outputs_: `p` y `div`. Durante la propagación del evento, hay 3 [fases](https://www.sitepoint.com/event-bubbling-javascript/): _capturing_, _target_ y _bubbling_. De forma predeterminada, los controladores de eventos se ejecutan en la fase uno (a menos que se establezca `useCapture` en `true`). Va desde el elemento anidado más profundo hacia el exterior.
---
-###### 33. What's the output?
+###### 33. ¿Qué devuelve la siguiente función?
```javascript
const person = { name: "Lydia" };
@@ -996,21 +996,21 @@ sayHi.bind(person, 21);
- C: `Lydia is 21` `Lydia is 21`
- D: `Lydia is 21` `function`
-Answer
+Solución
-#### Answer: D
+#### Respuesta correcta: D
-With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
+En ambos podemos pasar el objeto al que queremos que se refiera la palabra reservada `this`. Sin embargo, la diferencia es que `.call` es *ejecutado inmediatamente*!
-`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
+`.bind` devuelve una copia de la función, pero con un contexto enlazado. Es decir, no se ejecuta de inmediato.
---
-###### 34. What's the output?
+###### 34. ¿Qué devuelve la siguiente función?
```javascript
function sayHi() {
@@ -1025,21 +1025,21 @@ typeof sayHi();
- C: `"function"`
- D: `"undefined"`
-Answer
+Solución
-#### Answer: B
+#### Respuesta correcta: B
-The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+La función `sayHi` devuelve el valor devuelto de la función invocada inmediatamente ([IIFE](https://developer.mozilla.org/es/docs/Glossary/IIFE)). Esta función devuelve `0`, que es el tipo `"number"`.
-FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+En JS solo hay 7 tipos incorporados (En inglés se llaman _built-in types_, y pueden identificarse con el operador `typeof`. Más información [aquí](https://www.oreilly.com/library/view/you-dont-know/9781491905159/ch01.html)): `null`,` undefined`, `boolean`,` number`, `string`,` object` y `symbol`. `"function"` no es un tipo, ya que las funciones son objetos, es de tipo `"object"`.
---
-###### 35. Which of these values are falsy?
+###### 35. ¿Cuáles de estos valores son falsos?
```javascript
0;
@@ -1055,28 +1055,29 @@ undefined;
- C: `0`, `''`, `new Boolean(false)`, `undefined`
- D: All of them are falsy
-Answer
+Solución
-#### Answer: A
+#### Respuesta correcta: A
-There are only six falsy values:
+Solo hay seis valores falsos:
- `undefined`
- `null`
- `NaN`
- `0`
-- `''` (empty string)
+- `''` (cadena vacía)
- `false`
-Function constructors, like `new Number` and `new Boolean` are truthy.
+
+Los constructores de funciones, como `new Number` y `new Boolean` son correctos.
---
-###### 36. What's the output?
+###### 36. ¿Qué devuelve la siguiente función?
```javascript
console.log(typeof typeof 1);
@@ -1087,20 +1088,20 @@ console.log(typeof typeof 1);
- C: `"object"`
- D: `"undefined"`
-Answer
+Solución
-#### Answer: B
+#### Respuesta correcta: B
-`typeof 1` returns `"number"`.
-`typeof "number"` returns `"string"`
+`typeof 1` devuelve `"number" `.
+`typeof "number"` devuelve `"string"`
---
-###### 37. What's the output?
+###### 37. ¿Qué devuelve la siguiente función?
```javascript
const numbers = [1, 2, 3];
@@ -1113,23 +1114,23 @@ console.log(numbers);
- C: `[1, 2, 3, 7 x empty, 11]`
- D: `SyntaxError`
-Answer
+Solución
-#### Answer: C
+#### Respuesta correcta: C
-When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like:
+Cuando se establece un valor en un elemento de una matriz que excede la longitud de la matriz, JS crea algo llamado "ranuras vacías". Estos realmente tienen el valor de `undefined`, pero se podrá ver algo como:
`[1, 2, 3, 7 x empty, 11]`
-depending on where you run it (it's different for every browser, node, etc.)
+dependiendo de dónde lo ejecute (es diferente para cada navegador, nodo, etc.)
---
-###### 38. What's the output?
+###### 38. ¿Qué devuelve la siguiente función?
```javascript
(() => {
@@ -1150,46 +1151,46 @@ depending on where you run it (it's different for every browser, node, etc.)
- C: `1` `1` `2`
- D: `1` `undefined` `undefined`
-Answer
+Solución
-#### Answer: A
+#### Respuesta correcta: A
-The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
+El bloque `catch` recibe el argumento` x`. Este no es el mismo `x` que la variable cuando pasamos los argumentos. Esta variable `x` tiene un ámbito de bloque.
-Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+Más adelante, establecemos esta variable de ámbito de bloque igual a `1`, y establecemos el valor de la variable `y`. Ahora, registramos la variable de ámbito de bloque `x`, que es igual a `1`.
-Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+Fuera del bloque `catch`,` x` sigue siendo `undefined`, e `y` es `2`. Cuando queremos `console.log (x)` fuera del bloque `catch`, devuelve `undefined`, y `y` devuelve` 2`.
---
-###### 39. Everything in JavaScript is either a...
+###### 39. Todo en Javascript es o bien un(a)..
-- A: primitive or object
-- B: function or object
-- C: trick question! only objects
-- D: number or object
+- A: tipo primitivo o un objeto
+- B: función u objeto
+- C: ¡pregunta trampa! solo objetos
+- D: número u objeto
-Answer
+Solución
-#### Answer: A
+#### Respuesta correcta: A
-JavaScript only has primitive types and objects.
+JavaScript solo tiene tipos y objetos primitivos.
-Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+Los tipos primitivos son `boolean`, `null`, `undefined`, `bigint`, `number`, `string` y `symbol`.
-What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+Lo que diferencia a una tipo primitivo de un objeto es que los primeros no tienen propiedades o métodos; sin embargo, se puede ver que `'foo'.toUpperCase ()` se evalúa como `' FOO'` y no da como resultado un` TypeError`. Esto se debe a que cuando se intenta acceder a una propiedad o método en un tipo primitivo, como una cadena, JavaScript envolverá implícitamente el objeto utilizando una de las clases de envoltura, por ejemplo `string`, y luego descartará la envoltura inmediatamente después de evaluar la expresión. Todas los tipos primitivos excepto `null` y `undefined` poseen este comportamiento.
---
-###### 40. What's the output?
+###### 40. ¿Qué devuelve la siguiente función?
```javascript
[[0, 1], [2, 3]].reduce(
@@ -1205,21 +1206,21 @@ What differentiates a primitive from an object is that primitives do not have an
- C: `[1, 2, 0, 1, 2, 3]`
- D: `[1, 2, 6]`
-Answer
+Solución
-#### Answer: C
+#### Respuesta correcta: C
-`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
+`[1, 2]` es nuestro valor inicial. Este es el valor con el que empezamos y el valor del primer `acc`. Durante la primera ronda, `acc` es` [1,2] `, y `cur` es `[0, 1]`. Los concatenamos, lo que resulta en `[1, 2, 0, 1]`.
-Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
+Entonces, `[1, 2, 0, 1]` es `acc` y` [2, 3]` es `cur`. Los concatenamos, y obtenemos `[1, 2, 0, 1, 2, 3]`
---
-###### 41. What's the output?
+###### 41. ¿Qué devuelve la siguiente función?
```javascript
!!null;
@@ -1232,46 +1233,46 @@ Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and ge
- C: `false` `true` `true`
- D: `true` `true` `false`
-Answer
+Solución
-#### Answer: B
+#### Respuesta correcta: B
-`null` is falsy. `!null` returns `true`. `!true` returns `false`.
+`null` es falso. `! null` devuelve `true`. `! true` devuelve `false`.
-`""` is falsy. `!""` returns `true`. `!true` returns `false`.
+`" "` es falso. `!" "` devuelve `true`. `! true` devuelve `false`.
-`1` is truthy. `!1` returns `false`. `!false` returns `true`.
+'1' es verdadero. `! 1` devuelve `false`. `! false` devuelve `true`.
---
-###### 42. What does the `setInterval` method return?
+###### 42. ¿Qué devuelveel método `setInterval`?
```javascript
setInterval(() => console.log("Hi"), 1000);
```
-- A: a unique id
-- B: the amount of milliseconds specified
-- C: the passed function
+- A: una id único
+- B: la cantidad de milisegundos especificada
+- C: la función pasada
- D: `undefined`
-Answer
+Solución
-#### Answer: A
+#### Respuesta correcta: A
-It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function.
+Devuelve una identificación única, un id único. Este id se puede usar para borrar ese intervalo con la función `clearInterval ()`.
---
-###### 43. What does this return?
+###### 43. ¿Qué devuelve la siguiente función?
```javascript
[..."Lydia"];
@@ -1282,12 +1283,12 @@ It returns a unique id. This id can be used to clear that interval with the `cle
- C: `[[], "Lydia"]`
- D: `[["L", "y", "d", "i", "a"]]`
-Answer
+Solución
-#### Answer: A
+#### Respuesta correcta: A
-A string is an iterable. The spread operator maps every character of an iterable to one element.
+Una cadena es un iterable. El [operador de propagación](https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Operadores/Spread_operator) asigna todos los caracteres de un iterable a un elemento.
From ed56508b73b935971509fee8cfa57fcd22c60f60 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n?= <22575055+aguadotzn@users.noreply.github.com>
Date: Fri, 21 Jun 2019 11:00:57 +0200
Subject: [PATCH 048/881] Correct some typos
---
README-ES.md | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/README-ES.md b/README-ES.md
index 9f28798d..358e3c92 100644
--- a/README-ES.md
+++ b/README-ES.md
@@ -164,9 +164,9 @@ En JavaScript, todas las _keys_ son cadenas (a menos que sea un símbolo). A pes
JavaScript interpreta declaraciones. Cuando usamos la notación de corchetes, ve el corchete de apertura `[` y continúa hasta que encuentra el corchete de cierre `]`. Solo de esta manera se evaluará la afirmación.
-`mouse [bird.size]`: Primero evalúa `bird.size`, que es` "small" `. `mouse [" small "]` devuelve `true`
+`mouse [bird.size]`: Primero evalúa `bird.size`, que es` "small" `. `mouse ["small"]` devuelve `true`
-Sin embargo, con la notación de puntos, esto no sucede. `mouse` no tiene una clave llamada` bird`, lo que significa que `mouse.bird` es` undefined`. Luego, pedimos el `tamaño` usando la notación de puntos:` mouse.bird.size`. Como `mouse.bird` es` undefined`, en realidad estamos preguntando `undefined.size`. Esto no es válido y generará un error similar al `No se puede leer la propiedad" tamaño "de undefined`
+Sin embargo, con la notación de puntos, esto no sucede. `mouse` no tiene una clave llamada` bird`, lo que significa que `mouse.bird` es` undefined`. Luego, pedimos el `tamaño` usando la notación de puntos:` mouse.bird.size`. Como `mouse.bird` es` undefined`, en realidad estamos preguntando `undefined.size`. Esto no es válido y generará un error similar `al Cannot read property "size" of undefined`
@@ -194,7 +194,7 @@ console.log(d.greeting);
#### Respuesta correcta: A
-En JavaScript, TODOS los objetos interactúan por referencia, de modo que cuando se establecen iguales o pasan a una función, todos apuntan a la misma ubicación, de modo que cuando cambia un objeto, los cambia a todos.
+En JavaScript, TODOS los objetos interactúan por referencia, de modo que cuando se establecen iguales o pasan a una función, todos apuntan a la misma ubicación. De esta manera cuando cambia un objeto, los cambia a todos.
Primero, la variable `c` tiene un valor para un objeto. Más tarde, asignamos `d` con la misma referencia que` c` tiene al objeto.
@@ -233,7 +233,7 @@ console.log(b === c);
Cuando usamos el operador `==`, solo verifica si tiene el mismo _valor_. Ambos tienen el valor de `3`, por lo que devuelve` true`.
-Sin embargo, cuando usamos el operador `===`, tanto el valor _ como el tipo deben ser iguales. No es: `new Number ()` no es un número, es un ** objeto **. Ambos devuelven "falso".
+Sin embargo, cuando usamos el operador `===`, tanto el **valor** como el **tipo** deben ser iguales. Entonces: `new Number ()` no es un número, es un **objeto**. Ambos devuelven "false".
@@ -268,7 +268,7 @@ freddie.colorChange("orange");
#### Respuesta correcta: D
-La función `colorChange` es estática. Los métodos estáticos están diseñados para _vivir_ solo en el constructor en el que se crean y no se pueden transmitir a ningún elemento secundario. Como `freddie` es un niño, la función no se transmite y no está disponible en la instancia de` freddie`: por lo tanto se lanza un `TypeError`.
+La función `colorChange` es estática. Los métodos estáticos están diseñados para _vivir_ solo en el constructor en el que se crean y no se pueden transmitir a ningún elemento secundario. Como `freddie` es un niño, la función no se transmite y no está disponible en la instancia de `freddie`: por lo tanto se lanza un `TypeError`.
@@ -292,7 +292,7 @@ console.log(greetign);
#### Respuesta correcta: A
-Lo que hace JS aquí es registrar el objeto debido a que acabamos de crear un objeto vacío en el objeto global. Cuando escribimos erróneamente `greeting` como` greetign`, el intérprete de JS ve esto como `global.greetign = {}` (o `window.greetign = {}` en un navegador).
+Lo que hace JS aquí es registrar el objeto debido a que acabamos de crear un objeto vacío en el objeto global. Cuando escribimos erróneamente `greeting` como `greetign`, el intérprete de JS ve esto como `global.greetign = {}` (o `window.greetign = {}` en un navegador).
Para evitar esto, podemos usar el ["uso estricto"](https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Modo_estricto). Esto asegura que se haya declarado una variable antes de establecerla igual a cualquier cosa.
@@ -321,7 +321,7 @@ bark.animal = "dog";
#### Respuesta correcta: A
-Esto es perfectamente posible en JavaScript, porque las funciones son objetos (Recuerda: Todo aparte de los tipos primitivos son objetos en JS)
+Esto es perfectamente posible en JavaScript, porque las funciones son objetos (Recuerda: **todo** aparte de los tipos primitivos son objetos en JS)
Una función es un tipo especial de objeto. El código que escribes tú mismo no es la función real. La función es un objeto con propiedades. Esta propiedad es invocable.
@@ -1183,7 +1183,7 @@ JavaScript solo tiene tipos y objetos primitivos.
Los tipos primitivos son `boolean`, `null`, `undefined`, `bigint`, `number`, `string` y `symbol`.
-Lo que diferencia a una tipo primitivo de un objeto es que los primeros no tienen propiedades o métodos; sin embargo, se puede ver que `'foo'.toUpperCase ()` se evalúa como `' FOO'` y no da como resultado un` TypeError`. Esto se debe a que cuando se intenta acceder a una propiedad o método en un tipo primitivo, como una cadena, JavaScript envolverá implícitamente el objeto utilizando una de las clases de envoltura, por ejemplo `string`, y luego descartará la envoltura inmediatamente después de evaluar la expresión. Todas los tipos primitivos excepto `null` y `undefined` poseen este comportamiento.
+Lo que diferencia a un tipo primitivo de un objeto es que los primeros no tienen propiedades o métodos; sin embargo, se puede ver que `'foo'.toUpperCase ()` se evalúa como `'FOO'` y no da como resultado un `TypeError`. Esto se debe a que cuando se intenta acceder a una propiedad o método en un tipo primitivo, como una cadena, JavaScript envolverá implícitamente el objeto utilizando una de las clases de envoltura, por ejemplo `string`, y luego descartará la envoltura inmediatamente después de evaluar la expresión. Todas los tipos primitivos excepto `null` y `undefined` poseen este comportamiento.
From fe2c5bfd1552923f96c7697e52b683603ad9bbc2 Mon Sep 17 00:00:00 2001
From: KL13NT
Date: Fri, 21 Jun 2019 14:39:38 +0200
Subject: [PATCH 049/881] Finished Q.13
---
README_ar-EG.md | 336 ++++++++++++++++++++++++++++++++++--------------
1 file changed, 240 insertions(+), 96 deletions(-)
diff --git a/README_ar-EG.md b/README_ar-EG.md
index d935b106..247e318b 100644
--- a/README_ar-EG.md
+++ b/README_ar-EG.md
@@ -1,4 +1,6 @@
-# قائمة اسئلة جافاسكربت متقدمة
+
+
+# قائمة اسئلة جافاسكربت متقدمة
أنا بنشر أسئلة اختر جافاسكربت كل يوم على [انستجرام](https://www.instagram.com/theavocoder) واللي بدوري هنشرهم هنا
من البسيط للمتطور: اختبر نفسك في الجافاسكربت, افتكر حاجات كنت ناسيها, او جهز نفسك لمقابلة عمل جايه! :muscle: :rocket:
@@ -8,6 +10,7 @@
---
###### 1. ايه اللي هيتطبع؟
+
```javascript
function sayHi() {
@@ -19,6 +22,7 @@ function sayHi() {
sayHi();
```
+
- أ: `Lydia` و `undefined`
- ب: `Lydia` و `ReferenceError`
@@ -40,6 +44,7 @@ sayHi();
---
###### 2. ايه اللي هيتطبع؟
+
```javascript
for (var i = 0; i < 3; i++) {
@@ -50,6 +55,7 @@ for (let i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 1);
}
```
+
- أ: `0 1 2` و `0 1 2`
- ب: `0 1 2` و `3 3 3`
@@ -70,6 +76,7 @@ for (let i = 0; i < 3; i++) {
---
###### 3. ايه اللي هيتطبع؟
+
```javascript
const shape = {
@@ -83,6 +90,7 @@ const shape = {
shape.diameter();
shape.perimeter();
```
+
- أ: `20` و `62.83185307179586`
- ب: `20` و `NaN`
@@ -104,32 +112,36 @@ shape.perimeter();
---
-###### 4. What's the output?
+###### 4. ايه اللي هيتطبع؟
+
```javascript
+true;
!"Lydia";
```
+
-- A: `1` and `false`
-- B: `false` and `NaN`
-- C: `false` and `false`
+- أ: `1` و `false`
+- ب: `NaN` و `false`
+- ج: `false` و `false`
-
Answer
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
+علامة الجمع تحاول دائما ان تغير قيم من قيم مدخلاتها الى رقم باعتبار ان اي قيمة حقيقية ايجابية `true` يتم تحويلها لرقم `1` و القيم السالبية `false` تتحول الى `0`.
The unary plus tries to convert an operand to a number. `true` is `1`, and `false` is `0`.
-The string `'Lydia'` is a truthy value. What we're actually asking, is "is this truthy value falsy?". This returns `false`.
+و في الحالة دي القيمة الكتابية `'Lydia'` تعتبر ايجابية. هنا بقى السؤال: "هل القيمه الايجابيه دي سالبيه؟ و بالتالي الاجابة لا اللي هي `false`.
---
-###### 5. Which one is true?
+###### 5. اختر الاجابة الصحيحة
+
```javascript
const bird = {
@@ -141,24 +153,35 @@ const mouse = {
small: true
};
```
+
-- A: `mouse.bird.size` is not valid
-- B: `mouse[bird.size]` is not valid
-- C: `mouse[bird["size"]]` is not valid
-- D: All of them are valid
+- أ: `mouse.bird.size` متنفعش
+- ب: `mouse[bird.size]` متنفعش
+- ج: mouse[bird["size"]]` متنفعش
+- د: كلهم ينفعوا
-Answer
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
-In JavaScript, all object keys are strings (unless it's a Symbol). Even though we might not _type_ them as strings, they are always converted into strings under the hood.
+في جافاسكربت كل مفاتيح العناصر `object keys` من النوع `string` الا في حالة الـ `symbol`. وعلى الرغم من اننا ممكن منكتبهمش في شكل `string` فهما دايماً بيتحولوا ل`string`
+بص المثال:
+
-JavaScript interprets (or unboxes) statements. When we use bracket notation, it sees the first opening bracket `[` and keeps going until it finds the closing bracket `]`. Only then, it will evaluate the statement.
+```javascriptlet obj = {
+ size: 'big'
+}
+```
+
+
+في المثال ده احنا عملنا عنصر و كان ليه مفتاح اسمه size. شكل size احنا عاملينه من غير علامة التنصيص `""` ولكن لما البرنامج بيشتغل بيتم تحويلها الى سترنج و بالتالي بتكون في شكل `"size"`
-`mouse[bird.size]`: First it evaluates `bird.size`, which is `"small"`. `mouse["small"]` returns `true`
+غير بقى ان جافاسكربت بتفك كل جمله لوحدها. ده معناه انها لما بنستعمل علامات ال `[]` واسمها `bracket notation` هتفضل تمشي من اول `[` لحد ما توصل للي يقفله اللي هو `]`. و بعد كده هتقوم مشغله الجمله بعد ما تعرف ان الجمله دي مفيهاش اخطاء.
-However, with dot notation, this doesn't happen. `mouse` does not have a key called `bird`, which means that `mouse.bird` is `undefined`. Then, we ask for the `size` using dot notation: `mouse.bird.size`. Since `mouse.bird` is `undefined`, we're actually asking `undefined.size`. This isn't valid, and will throw an error similar to `Cannot read property "size" of undefined`.
+فا عشان كده عندنا `mouse[bird.size]` الاول هتجيب `bird.size` اللي قيمته `"small"` وبالتالي تبقى الجمله `mouse["small"]` هترجع `true`
+
+ولكن لما بنستعمل ال `dot notation` مبيحصلش كده. `mouse` ملوش مفتاح اسمه `bird` و بالتالي احنا بنطلب قيمه موجوده جوا حاجه مش موجودة اصلاً و بالتالي بيرجعلنا خطأ `cannot read property of undefined`.
@@ -167,7 +190,8 @@ However, with dot notation, this doesn't happen. `mouse` does not have a key cal
---
-###### 6. What's the output?
+###### 6. ايه اللي هيتطبع؟
+
```javascript
let c = { greeting: "Hey!" };
@@ -177,32 +201,35 @@ d = c;
c.greeting = "Hello";
console.log(d.greeting);
```
+
-- A: `Hello`
-- B: `Hey`
-- C: `undefined`
-- D: `ReferenceError`
-- E: `TypeError`
+- أ: `Hello`
+- ب: `Hey`
+- ج: `undefined`
+- د: `ReferenceError`
+- هـ: `TypeError`
-Answer
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
-In JavaScript, all objects interact by _reference_ when setting them equal to each other.
+في جافاسكربت كل العناصر `objects` بيتعاملوا بالـ`reference` لما بنساويهم ببعض. ده معناه ان الاوبجكت مش بيتعمل منه نسخه جديدة و انما بيتم الاشارة اليه بأسم جديد مش اكتر.
-First, variable `c` holds a value to an object. Later, we assign `d` with the same reference that `c` has to the object.
+في الاول المتغير `c` جواه قيمة اوبجكت و بعد كده بنقوم عاملين اشارة للاوبجكت ده عن طريق المتغير `d`
+.
-When you change one object, you change all of them.
+وبالتالي لما بتغير متغير واحد منهم انت بتغير الاتنين لان الاتنين بيشيروا لنفس العنصر في الميموري.
---
-###### 7. What's the output?
+###### 7. ايه اللي هيتطبع؟
+
```javascript
let a = 3;
@@ -213,29 +240,31 @@ console.log(a == b);
console.log(a === b);
console.log(b === c);
```
+
-- A: `true` `false` `true`
-- B: `false` `false` `true`
-- C: `true` `false` `false`
-- D: `false` `true` `true`
+- أ: `true` `false` `true`
+- ب: `false` `false` `true`
+- ج: `true` `false` `false`
+- د: `false` `true` `true`
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة الصحيحة: ج
-`new Number()` is a built-in function constructor. Although it looks like a number, it's not really a number: it has a bunch of extra features and is an object.
+`new Number()` ده `constructor` مبني في اللغه و على الرغم من ان شكل القيمه اللي هتطلع منه مجرد رقم `primitive` لكن الحقيقه ان القيمة اللي هتيجي `object` وهيكون فيه زيادات زي ال`methods` وهكذا.
-When we use the `==` operator, it only checks whether it has the same _value_. They both have the value of `3`, so it returns `true`.
+لما بنستعمل علامة المساواه `==` احنا بنشوف بس لو القيمتين اللي بنقارنهم ليهم نفس **القيمة** فقط ولا لا. الاتنين ليهم قيمة `3` وبالتالي هترجع `true`
-However, when we use the `===` operator, both value _and_ type should be the same. It's not: `new Number()` is not a number, it's an **object**. Both return `false.`
+اما بقى لما بنستعمل المساواة `===` احنا بنشوف **القيمة** و **النوع** و بالتالي بما ان الاتنين `object` بس موجودين في اماكن مختلفه في الميموري اذاً احنا مش عاملين اشارة لنفس العنصر و بالتالي هترجع `false`.
---
-###### 8. What's the output?
+###### 8. ايه اللي هيتطبع؟
+
```javascript
class Chameleon {
@@ -252,51 +281,55 @@ class Chameleon {
const freddie = new Chameleon({ newColor: "purple" });
freddie.colorChange("orange");
```
+
-- A: `orange`
-- B: `purple`
-- C: `green`
-- D: `TypeError`
+- أ: `orange`
+- ب: `purple`
+- ج: `green`
+- د: `TypeError`
-Answer
+الاجابة
-#### Answer: D
+#### الاجابة الصحيحة: د
-The `colorChange` function is static. Static methods are designed to live only on the constructor in which they are created, and cannot be passed down to any children. Since `freddie` is a child, the function is not passed down, and not available on the `freddie` instance: a `TypeError` is thrown.
+الدالة `colorChange` من نوع `static` و بالتالي هي مموجوده فقط في ال`constructor` اللي بتتعمل فيه و مش بتروح لأي عنصر بيتعمل من ال`class` ده و بما ان `freddie` ده عنصر معمول من الكلاس ده فا الدالة `colorChange` مش بتروحله و بالتالي مش موجوده معاه و عشان كده هتدينا `TypeError`.
---
-###### 9. What's the output?
+###### 9. ايه اللي هيتطبع؟
+
```javascript
let greeting;
greetign = {}; // Typo!
console.log(greetign);
```
+
-- A: `{}`
-- B: `ReferenceError: greetign is not defined`
-- C: `undefined`
+- أ: `{}`
+- ب: `ReferenceError: greetign is not defined`
+- ج: `undefined`
-Answer
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
-It logs the object, because we just created an empty object on the global object! When we mistyped `greeting` as `greetign`, the JS interpreter actually saw this as `global.greetign = {}` (or `window.greetign = {}` in a browser).
+بتطبع العنصر الفاضي لأننا عملنا الاوبجكت ده من نوع `global` لما كتبنا `greetign` بدل `greeting` و بالتالي البرنامج شاف `greetign` على انها `window.greetign={}` لو في المتصفح.
-In order to avoid this, we can use `"use strict"`. This makes sure that you have declared a variable before setting it equal to anything.
+عشان نبعد عن المشكلة دي نقدر نستعمل `"use strict"` و اللي بدورها بتتأكد ان انت عملت المتغير قبل ما تحاول تتعامل معاه.
---
-###### 10. What happens when we do this?
+###### 10. ايه اللي هيحصل لما نعمل كده؟
+
```javascript
function bark() {
@@ -305,27 +338,28 @@ function bark() {
bark.animal = "dog";
```
+
-- A: Nothing, this is totally fine!
-- B: `SyntaxError`. You cannot add properties to a function this way.
-- C: `undefined`
-- D: `ReferenceError`
+- أ: مش هيحصل اي حاجه غلط, الكود ده صحيح تماماً!
+- ب: `SyntaxError`
+- ج: `undefined`
+- د: `ReferenceError`
-Answer
-
-#### Answer: A
+الاجابة
+
-This is possible in JavaScript, because functions are objects! (Everything besides primitive types are objects)
+#### الاجابة الصحيحة: أ
-A function is a special type of object. The code you write yourself isn't the actual function. The function is an object with properties. This property is invocable.
+كل حاجه في جافاسكربت عبارة عن `object` حتى الدوال و بالتالي نقدر بكل سهولة اننا نعمل اللي احنا عملناه في الكود و نضيف مفاتيح و قيم للداله على انها عنصر اوبجكت عادي جداً.
---
-###### 11. What's the output?
+###### 11. ايه اللي هيتطبع؟
+
```javascript
function Person(firstName, lastName) {
@@ -340,33 +374,40 @@ Person.getFullName = function() {
console.log(member.getFullName());
```
+
-- A: `TypeError`
-- B: `SyntaxError`
-- C: `Lydia Hallie`
-- D: `undefined` `undefined`
+- أ: `TypeError`
+- ب: `SyntaxError`
+- ج: `Lydia Hallie`
+- د: `undefined` `undefined`
-Answer
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
+
+مينفعش تضيف قيم لـ `constructor`بالشكل ده. لو عايز تضيف قيمة لكل الاوبجكتس اللي معمولين من الـ`constructor` ده لازم تستعمل الـ `prototype`
-You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all objects at once, you have to use the prototype instead. So in this case,
+بص المثال ده:
+
```js
Person.prototype.getFullName = function() {
return `${this.firstName} ${this.lastName}`;
};
```
+
+
+في المثال ده هنقدر نضيف القيمه لكل العناصر اللي معموله من الـ`constructor` ده. ايه الفايده من ده بقى؟ تخيل معايا ان احنا عملنا كوبي من دالة دي جوا كل عنصر لوحدة --مع التغاضي عن اعتبار ان بعضهم ممكن ميكونوش محتاجينها اصلاً-- احنا كده بنستخدم ميموري كتير جداً على الفاضي بينما عن طريق الـ`prototype` بنقدر اننا نعملها مره واحدة فقط و بتكون موجوده لكل العناصر اللي معموله منها!
-would have made `member.getFullName()` work. Why is this beneficial? Say that we added this method to the constructor itself. Maybe not every `Person` instance needed this method. This would waste a lot of memory space, since they would still have that property, which takes of memory space for each instance. Instead, if we only add it to the prototype, we just have it at one spot in memory, yet they all have access to it!
---
-###### 12. What's the output?
+###### 12. ايه اللي هيتطبع؟
+
```javascript
function Person(firstName, lastName) {
@@ -380,39 +421,39 @@ const sarah = Person("Sarah", "Smith");
console.log(lydia);
console.log(sarah);
```
+
-- A: `Person {firstName: "Lydia", lastName: "Hallie"}` and `undefined`
-- B: `Person {firstName: "Lydia", lastName: "Hallie"}` and `Person {firstName: "Sarah", lastName: "Smith"}`
-- C: `Person {firstName: "Lydia", lastName: "Hallie"}` and `{}`
-- D:`Person {firstName: "Lydia", lastName: "Hallie"}` and `ReferenceError`
+- أ: `Person {firstName: "Lydia", lastName: "Hallie"}` و `undefined`
+- ب: `Person {firstName: "Lydia", lastName: "Hallie"}` و `Person {firstName: "Sarah", lastName: "Smith"}`
+- ج: `Person {firstName: "Lydia", lastName: "Hallie"}` و `{}`
+- د: `Person {firstName: "Lydia", lastName: "Hallie"}` و `ReferenceError`
-Answer
+الاجابة
-#### Answer: A
-
-For `sarah`, we didn't use the `new` keyword. When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
+#### الاجابة الصحيحة: أ
-We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smith"`. What we actually did, is defining `global.firstName = 'Sarah'` and `global.lastName = 'Smith'`. `sarah` itself is left `undefined`.
+كلمة `new` بتشير الى الاوبجكت الفاضي الجديد اللي احنا بنعمله قبل ما يتم اضافة اي قيم ليه. لكن لما مش بتستعمل `new` بيتم الاشارة الى الـ`global` او `window` على حسب انت بتشغل الكود فين و بالتالي لما عملنا `this.firstName = "Sarah"` احنا كده كأننا قولنا `window.firstName = "Sarah"` وبالتالي الاوبجكت `sarah نفسه فضل `undefined`
---
-###### 13. What are the three phases of event propagation?
+###### 13. ايه الـ3 مراحل بتوع الـ `event propagation`؟
-- A: Target > Capturing > Bubbling
-- B: Bubbling > Target > Capturing
-- C: Target > Bubbling > Capturing
-- D: Capturing > Target > Bubbling
+- أ: Target > Capturing > Bubbling
+- ب: Bubbling > Target > Capturing
+- ج: Target > Bubbling > Capturing
+- د: Capturing > Target > Bubbling
-Answer
+الاجابة
-#### Answer: D
+#### الاجابة الصحيحة: د
+
+في مرحلة الـ`capturing` الحدث بيمر الاول خلال العناصر الكبيره المحتوية على العنصر اللي حصلت فيه الحدث اصلاً لحد ما توصل للعنصر ده. بعد كده بتوصل لـ `target` واللي هو العنصر اللي عمل الحدث و بعد كده بترد تاني لفوق في مرحلة الـ`bubbling`
-During the **capturing** phase, the event goes through the ancestor elements down to the target element. It then reaches the **target** element, and **bubbling** begins.
@@ -421,10 +462,10 @@ During the **capturing** phase, the event goes through the ancestor elements dow
---
-###### 14. All object have prototypes.
+###### 14. كل العناصر `objects` ليهم `prototype`. هذه العبارة:
-- A: true
-- B: false
+- أ: صحيحة
+- ب: خطأ
Answer
@@ -439,6 +480,7 @@ All objects have prototypes, except for the **base object**. The base object has
---
###### 15. What's the output?
+
```javascript
function sum(a, b) {
@@ -447,6 +489,7 @@ function sum(a, b) {
sum(1, "2");
```
+
- A: `NaN`
- B: `TypeError`
@@ -469,12 +512,15 @@ In this example, JavaScript converts the number `1` into a string, in order for
###### 16. What's the output?
+
+
```javascript
let number = 0;
console.log(number++);
console.log(++number);
console.log(number);
```
+
- A: `1` `1` `2`
- B: `1` `2` `2`
@@ -505,6 +551,8 @@ This returns `0 2 2`.
###### 17. What's the output?
+
+
```javascript
function getPersonInfo(one, two, three) {
console.log(one);
@@ -517,6 +565,8 @@ const age = 21;
getPersonInfo`${person} is ${age} years old`;
```
+
+
- A: `"Lydia"` `21` `["", " is ", " years old"]`
- B: `["", " is ", " years old"]` `"Lydia"` `21`
@@ -536,6 +586,8 @@ If you use tagged template literals, the value of the first argument is always a
###### 18. What's the output?
+
+
```javascript
function checkAge(data) {
if (data === { age: 18 }) {
@@ -549,6 +601,8 @@ function checkAge(data) {
checkAge({ age: 18 });
```
+
+
- A: `You are an adult!`
- B: `You are still an adult.`
@@ -572,6 +626,8 @@ This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }`
###### 19. What's the output?
+
+
```javascript
function getAge(...args) {
console.log(typeof args);
@@ -579,6 +635,8 @@ function getAge(...args) {
getAge(21);
```
+
+
- A: `"number"`
- B: `"array"`
@@ -599,6 +657,8 @@ The spread operator (`...args`.) returns an array with arguments. An array is an
###### 20. What's the output?
+
+
```javascript
function getAge() {
"use strict";
@@ -608,6 +668,8 @@ function getAge() {
getAge();
```
+
+
- A: `21`
- B: `undefined`
@@ -628,9 +690,13 @@ With `"use strict"`, you can make sure that you don't accidentally declare globa
###### 21. What's value of `sum`?
+
+
```javascript
const sum = eval("10*10+5");
```
+
+
- A: `105`
- B: `"105"`
@@ -651,9 +717,13 @@ const sum = eval("10*10+5");
###### 22. How long is cool_secret accessible?
+
+
```javascript
sessionStorage.setItem("cool_secret", 123);
```
+
+
- A: Forever, the data doesn't get lost.
- B: When the user closes the tab.
@@ -676,12 +746,16 @@ If you used `localStorage`, the data would've been there forever, unless for exa
###### 23. What's the output?
+
+
```javascript
var num = 8;
var num = 10;
console.log(num);
```
+
+
- A: `8`
- B: `10`
@@ -704,6 +778,8 @@ You cannot do this with `let` or `const` since they're block-scoped.
###### 24. What's the output?
+
+
```javascript
const obj = { 1: "a", 2: "b", 3: "c" };
const set = new Set([1, 2, 3, 4, 5]);
@@ -713,6 +789,8 @@ obj.hasOwnProperty(1);
set.has("1");
set.has(1);
```
+
+
- A: `false` `true` `false` `true`
- B: `false` `true` `true` `true`
@@ -735,10 +813,14 @@ It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')`
###### 25. What's the output?
+
+
```javascript
const obj = { a: "one", b: "two", a: "three" };
console.log(obj);
```
+
+
- A: `{ a: "one", b: "two" }`
- B: `{ b: "two", a: "three" }`
@@ -777,12 +859,16 @@ The base execution context is the global execution context: it's what's accessib
###### 27. What's the output?
+
+
```javascript
for (let i = 1; i < 5; i++) {
if (i === 3) continue;
console.log(i);
}
```
+
+
- A: `1` `2`
- B: `1` `2` `3`
@@ -803,6 +889,8 @@ The `continue` statement skips an iteration if a certain condition returns `true
###### 28. What's the output?
+
+
```javascript
String.prototype.giveLydiaPizza = () => {
return "Just give Lydia pizza already!";
@@ -812,6 +900,8 @@ const name = "Lydia";
name.giveLydiaPizza();
```
+
+
- A: `"Just give Lydia pizza already!"`
- B: `TypeError: not a function`
@@ -832,6 +922,8 @@ name.giveLydiaPizza();
###### 29. What's the output?
+
+
```javascript
const a = {};
const b = { key: "b" };
@@ -842,6 +934,8 @@ a[c] = 456;
console.log(a[b]);
```
+
+
- A: `123`
- B: `456`
@@ -866,6 +960,8 @@ Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to
###### 30. What's the output?
+
+
```javascript
const foo = () => console.log("First");
const bar = () => setTimeout(() => console.log("Second"));
@@ -875,6 +971,8 @@ bar();
foo();
baz();
```
+
+
- A: `First` `Second` `Third`
- B: `First` `Third` `Second`
@@ -918,6 +1016,7 @@ This is where an event loop starts to work. An **event loop** looks at the stack
---
###### 31. What is the event.target when clicking the button?
+
```html
@@ -928,6 +1027,8 @@ This is where an event loop starts to work. An **event loop** looks at the stack
```
+
+
- A: Outer `div`
- B: Inner `div`
@@ -947,6 +1048,7 @@ The deepest nested element that caused the event is the target of the event. You
---
###### 32. When you click the paragraph, what's the logged output?
+
```html
@@ -955,6 +1057,7 @@ The deepest nested element that caused the event is the target of the event. You
```
+
- A: `p` `div`
- B: `div` `p`
@@ -975,6 +1078,8 @@ If we click `p`, we see two logs: `p` and `div`. During event propagation, there
###### 33. What's the output?
+
+
```javascript
const person = { name: "Lydia" };
@@ -985,6 +1090,8 @@ function sayHi(age) {
sayHi.call(person, 21);
sayHi.bind(person, 21);
```
+
+
- A: `undefined is 21` `Lydia is 21`
- B: `function` `function`
@@ -1007,6 +1114,8 @@ With both, we can pass the object to which we want the `this` keyword to refer t
###### 34. What's the output?
+
+
```javascript
function sayHi() {
return (() => 0)();
@@ -1014,6 +1123,8 @@ function sayHi() {
typeof sayHi();
```
+
+
- A: `"object"`
- B: `"number"`
@@ -1036,6 +1147,8 @@ FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`,
###### 35. Which of these values are falsy?
+
+
```javascript
0;
new Number(0);
@@ -1044,6 +1157,8 @@ new Number(0);
new Boolean(false);
undefined;
```
+
+
- A: `0`, `''`, `undefined`
- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
@@ -1073,9 +1188,13 @@ Function constructors, like `new Number` and `new Boolean` are truthy.
###### 36. What's the output?
+
+
```javascript
console.log(typeof typeof 1);
```
+
+
- A: `"number"`
- B: `"string"`
@@ -1097,11 +1216,15 @@ console.log(typeof typeof 1);
###### 37. What's the output?
+
+
```javascript
const numbers = [1, 2, 3];
numbers[10] = 11;
console.log(numbers);
```
+
+
- A: `[1, 2, 3, 7 x null, 11]`
- B: `[1, 2, 3, 11]`
@@ -1126,6 +1249,8 @@ depending on where you run it (it's different for every browser, node, etc.)
###### 38. What's the output?
+
+
```javascript
(() => {
let x, y;
@@ -1139,6 +1264,8 @@ depending on where you run it (it's different for every browser, node, etc.)
console.log(y);
})();
```
+
+
- A: `1` `undefined` `2`
- B: `undefined` `undefined` `undefined`
@@ -1186,6 +1313,8 @@ What differentiates a primitive from an object is that primitives do not have an
###### 40. What's the output?
+
+
```javascript
[[0, 1], [2, 3]].reduce(
(acc, cur) => {
@@ -1194,6 +1323,8 @@ What differentiates a primitive from an object is that primitives do not have an
[1, 2]
);
```
+
+
- A: `[0, 1, 2, 3, 1, 2]`
- B: `[6, 1, 2]`
@@ -1216,11 +1347,15 @@ Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and ge
###### 41. What's the output?
+
+
```javascript
!!null;
!!"";
!!1;
```
+
+
- A: `false` `true` `false`
- B: `false` `false` `true`
@@ -1245,9 +1380,13 @@ Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and ge
###### 42. What does the `setInterval` method return in the browser?
+
+
```javascript
setInterval(() => console.log("Hi"), 1000);
```
+
+
- A: a unique id
- B: the amount of milliseconds specified
@@ -1268,9 +1407,13 @@ It returns a unique id. This id can be used to clear that interval with the `cle
###### 43. What does this return?
+
+
```javascript
[..."Lydia"];
```
+
+
- A: `["L", "y", "d", "i", "a"]`
- B: `["Lydia"]`
@@ -1286,3 +1429,4 @@ A string is an iterable. The spread operator maps every character of an iterable
+
\ No newline at end of file
From cf7ce10142235e101320e2e15527a8b1ffda9f63 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 21 Jun 2019 15:15:34 +0200
Subject: [PATCH 050/881] Create README_AR.md
Add an Arabic translation for the Repository.
In this commit, translation is done until the third question.
---
README_AR.md | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 127 insertions(+)
create mode 100644 README_AR.md
diff --git a/README_AR.md b/README_AR.md
new file mode 100644
index 00000000..43351549
--- /dev/null
+++ b/README_AR.md
@@ -0,0 +1,127 @@
+
+
+
+
+# قائــمة أسئلة جافا سكريبت (مستوى متقدم)
+أقوم بنشر عدة أسئلة جافاسكريبت بصورة يومية على حسابي في [انستغرام](https://www.instagram.com/theavocoder/).
+
+تتدرج الأسئلة إبتداءا من المستوى الأساسي أو البسيط الى المستوى المتقدم لإختبار مدى معرفتك بلغة الجافا سكريبت, قم بمراجعة و إنعاش معرفتك باللغة قليلا, أو قم بالتجهيز لمقابلة عمل لوظيفة مبرمج عن طريق هذه الأسئلة!
+
+أقوم بتحديث هذا المستودع أسبوعيا بإضافة المزيد من الأسئلة. :muscle: :rocket:
+
+الأجوبة توجد في الجزء المطوي بالأسفل أدناه تحت كل سؤال على حدة, فقط قم بالضغط على كلمة الإجابة لكي تحصل على الإجابة, حظا موفقا :heart:
+
+[English](https://github.com/SaraAli26/javascript-questions/blob/master/README.md)
+
+[中文版本](https://github.com/SaraAli26/javascript-questions/blob/master/README-zh_CN.md)
+
+[Русский](https://github.com/SaraAli26/javascript-questions/blob/master/README_ru-RU.md)
+
+[Western Balkan](https://github.com/SaraAli26/javascript-questions/blob/master/README-bs_BS.md)
+
+[Deutsch](https://github.com/SaraAli26/javascript-questions/blob/master/README-de_DE.md)
+
+[Tiếng Việt](https://github.com/SaraAli26/javascript-questions/blob/master/README-vi.md)
+
+____________
+
+###### 1. ماهو الناتج ؟
+
+```javascript
+function sayHi() {
+ console.log(name);
+ console.log(age);
+ var name = "Lydia";
+ let age = 21;
+}
+
+sayHi();
+```
+
+- A: `Lydia` and `undefined`
+- B: `Lydia` and `ReferenceError`
+- C: `ReferenceError` and `21`
+- D: `undefined` and `ReferenceError`
+
+الإجابة
+
+
+
+الإجابة هي الخيار الرابع : D
+
+في داخل الدالة, قمنا أولا بتعريف المتغير `name` مع الكلمة المفتاحية `var`. و هذا يعني ان المتغير قد حصلت له عملية hoisting والتي تعني انه قد تم حجز مساحة لهذا المتغير في هذه اللحظة مع قيمة مبدئية و التي هي `undefined` إلى ان نقوم فعليا بتعريف قيمة له لاحقا.
+لم نقم بتعريف المتغير `name` بعد عندما قمنا بطباعته في السطر الاول من الدالة, لهذا لايزال يحمل القيمة `undefined`.
+المتغيرات التي تم تعريفها بجانب الكلمات المفتاحية `let` و `const` يتم عمل عملية hoisting لها أيضا, ولكن على عكس المتغيرات التي يتم تعريفها بجانب الكلمة المفتاحية `var`, لا يتم تعريفها او الوصول اليها مالم نقم بإضافة قيمة لها فعليا. و يسمى هذا بال"temporal dead zone".عندما نحاول الوصول الى المتغيرات من النوع `var`قبل ان يتم تعريفها, نتحصل على الخطأ التالي `ReferenceError`.
+
+
+
+
+
+---
+
+2. ماهو الناتج?
+
+```javascript
+for (var i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+
+for (let i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+```
+
+- A: `0 1 2` and `0 1 2`
+- B: `0 1 2` and `3 3 3`
+- C: `3 3 3` and `0 1 2`
+
+الإجابة
+
+
+
+الإجابة هي الخيار الثالث: C
+
+بسبب ترتيب تسلسل الأحداث في الجافا سكريبت, دالة `setTimeout` والتي هي دالة من نوع callbackقد تم استدعائها بعد ان تم تنفيذ ال loop. بماأن المتغير `i` في الloop الاولى قد تم تعريفه عن طريق الكلمة المفتاحية `var` فإن هذه القيمة هي glopal. أثناء تنفيذ هذه ال loop قد تم إضافة 1 الى المتغير `var` في كل دورة باستخدام العملية `++`. بنهاية الدورة و عندما تم استدعاء الدالة `setTimeout` كانت قيمة المتغير `i` قد أصبحت تساوي `3` في المثال الأول.
+في الloop الثانية ,تم تعريف المتغير `i` باستخدام الكلمة المفتاحية `let` المتغيرات التي يتم تعريفها باستخدام الكلمات المفتاحية `let` و `const` هي متغيرات تنتمي فقط للBlock الذي تم تعريفها بداخله, والذي هو بين القوسين, أثناءتنفيذ الloop, سنقوم بالتحصل على قيمة جديدة للمتغير `i` في نهاية كل دورة , وأي قيمة تكون منتمية للScope بداخل الloop.
+
+
+
+
+
+---
+
+3. ماهو الناتج?
+
+```javascript
+const shape = {
+ radius: 10,
+ diameter() {
+ return this.radius * 2;
+ },
+ perimeter: () => 2 * Math.PI * this.radius
+};
+
+shape.diameter();
+shape.perimeter();
+```
+
+- A: `20` and `62.83185307179586`
+- B: `20` and `NaN`
+- C: `20` and `63`
+- D: `NaN` and `63`
+
+
الإجابة
+
+
+الجواب هو الخيار الثاني: B
+
+يرجى ملاحظة أن قيمة`diameter` هي دالة Regular و في المقابل قيمة `perimeter` هي دالة من النوع arrow.
+في حال استخدام دوال ال arrow, الكلمة المفتاحية `this` ترجع و تدل على المحيط الحالي الذي توجد به الكلمة المفتاحية, على عكس وجود الكلمة المفتاحية `this` في الدالة العادية حيث أنها تعني اننا نقوم بمناداة `perimeter` و هي لا تعني اننا نقصد الshape object بل نقصد الscope الذي يحاوطه, على سبيل المثال : Window.
+
+لا توجد قيمة `radius` في ذلك ال object لهذا يقوم بإرجاع القيمة `undefined`.
+
+
+
+
+
+---
From 98591f65ed51d55b8266e3cea01696750e823eb3 Mon Sep 17 00:00:00 2001
From: Guilherme Nogara
Date: Fri, 21 Jun 2019 10:21:30 -0300
Subject: [PATCH 051/881] Linha 5 refresce -> refresque
---
README_pt_BR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_pt_BR.md b/README_pt_BR.md
index 64bd9504..6970c2ec 100644
--- a/README_pt_BR.md
+++ b/README_pt_BR.md
@@ -2,7 +2,7 @@
Posto questões de múltipla escolha sobre JavaScript no meu [Instagram](https://www.instagram.com/theavocoder), as quais também posto aqui!
-Do básico ao avançado: Teste quão bem você conhece o JavaScript, refresce um pouco do seu conhecimento, ou se prepare para uma entrevista! :muscle: :rocket: Eu atualizo esse repositório semanalmente com novas questões.
+Do básico ao avançado: Teste quão bem você conhece o JavaScript, refresque um pouco do seu conhecimento, ou se prepare para uma entrevista! :muscle: :rocket: Eu atualizo esse repositório semanalmente com novas questões.
As respostas estão em seções recolhidas abaixo das questões, basta clicar nelas para expandir. Boa sorte :heart:
From 03220b5f450b5e16932ed0610814903db6812c7a Mon Sep 17 00:00:00 2001
From: Guilherme Nogara
Date: Fri, 21 Jun 2019 10:21:30 -0300
Subject: [PATCH 052/881] Linha 5 refresce -> refresque
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Também removi um separador duplicado, conforme https://github.com/lydiahallie/javascript-questions/pull/74
---
README_pt_BR.md | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/README_pt_BR.md b/README_pt_BR.md
index 64bd9504..425653ca 100644
--- a/README_pt_BR.md
+++ b/README_pt_BR.md
@@ -2,7 +2,7 @@
Posto questões de múltipla escolha sobre JavaScript no meu [Instagram](https://www.instagram.com/theavocoder), as quais também posto aqui!
-Do básico ao avançado: Teste quão bem você conhece o JavaScript, refresce um pouco do seu conhecimento, ou se prepare para uma entrevista! :muscle: :rocket: Eu atualizo esse repositório semanalmente com novas questões.
+Do básico ao avançado: Teste quão bem você conhece o JavaScript, refresque um pouco do seu conhecimento, ou se prepare para uma entrevista! :muscle: :rocket: Eu atualizo esse repositório semanalmente com novas questões.
As respostas estão em seções recolhidas abaixo das questões, basta clicar nelas para expandir. Boa sorte :heart:
@@ -176,8 +176,6 @@ Por outro lado, com a notação de ponto `.`, isso não acontece. `mouse` não t
---
----
-
###### 6. Qual é a saída?
```javascript
From e1f777bdd116bfdf15ee9d89a3b4968ce7d343b3 Mon Sep 17 00:00:00 2001
From: Guilherme Nogara
Date: Fri, 21 Jun 2019 11:12:12 -0300
Subject: [PATCH 053/881] Linha 136 falsey -> falsy
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mais alguns casos que termos usando `` não eram seguidos por espaço quando no meio da sentença.
---
README_pt_BR.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README_pt_BR.md b/README_pt_BR.md
index 425653ca..b90a88d8 100644
--- a/README_pt_BR.md
+++ b/README_pt_BR.md
@@ -133,7 +133,7 @@ Não há `radius` fora de shape, então retorna `undefined`.
O operador unário `+` tenta converter um operando para um número. `true` é `1`, e `false` é `0`.
A string `'Lydia'` tem valor truthy*. O que estamos realmente perguntando é "Esse valor truthy é falsy?". Isso retorna `false`.
-###### *Nota do tradutor: truthy é um termo único ao JavaScript que denota valores que podem ser convertidos em um booleano `True`. Sua contraparte é falsey, que são valores que podem ser convertidos em um booleano `false`. Para fins de consistência, mantenho os termos originais.
+###### *Nota do tradutor: truthy é um termo único ao JavaScript que denota valores que podem ser convertidos em um booleano `True`. Sua contraparte é falsy, que são valores que podem ser convertidos em um booleano `false`. Para fins de consistência, mantenho os termos originais.
@@ -237,7 +237,7 @@ console.log(b === c);
Quando usamos o operador `==`, só conferimos se ambas tem o mesmo
valor. Ambas tem o valor de `3`, então retorna `true`.
-Contudo, quando usamos o operador `===`, ambos valor
e tipo tem de ser o mesmo. E não é: `new Number()` não é um número, é um **objeto**. Ambos retornam `false`.
+Contudo, quando usamos o operador `===`, ambos valor
e tipo tem de ser o mesmo. E não são: `new Number()` não é um número, é um **objeto**. Ambos retornam `false`.
@@ -371,7 +371,7 @@ Person.prototype.getFullName = function() {
};
```
-faria `member.getFullName()` funcionar. Por quê isso é beneficial? Digamos que tivéssemos esse método ao próprio construtor. Talvez nem toda instância de `Person` precisasse desse método. Isso gastaria muita memória, uma vez que cada instância teria esse propriedade e teria seu espaço alocado. Ao invés disso, se adicionarmos somente ao protótipo, alocamos somente um único espaço na memória, e todas instâncias de `Person`ainda tem acesso ao método.
+faria `member.getFullName()` funcionar. Por quê isso é beneficial? Digamos que tivéssemos esse método no próprio construtor. Talvez nem toda instância de `Person` precisasse desse método. Isso gastaria muita memória, uma vez que cada instância teria esse propriedade e teria seu espaço alocado. Ao invés disso, se adicionarmos somente ao protótipo, alocamos somente um único espaço na memória, e todas instâncias de `Person` ainda tem acesso ao método.
From 2107ac27374ba8dcdde03afd74de3db092168854 Mon Sep 17 00:00:00 2001
From: Lydia
Date: Fri, 21 Jun 2019 17:08:22 +0200
Subject: [PATCH 054/881] Add questions 44 to 54
---
README.md | 358 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 358 insertions(+)
diff --git a/README.md b/README.md
index 916fa133..ee0c29a3 100644
--- a/README.md
+++ b/README.md
@@ -1295,3 +1295,361 @@ A string is an iterable. The spread operator maps every character of an iterable
+
+---
+
+###### 44. What's the output?
+
+```javascript
+function* generator(i) {
+ yield i;
+ yield i * 2;
+}
+
+const gen = generator(10);
+
+console.log(gen.next().value);
+console.log(gen.next().value);
+```
+
+- A: `[0, 10], [10, 20]`
+- B: `20, 20`
+- C: `10, 20`
+- D: `0, 10 and 10, 20`
+
+Answer
+
+
+#### Answer: C
+
+Regular functions cannot be stopped mid-way after invocation. However, a generator function can be "stopped" midway, and later continue from where it stopped. Every time a generator function encounters a `yield` keyword, the function yields the value specified after it. Note that the generator function in that case doesn’t _return_ the value, it _yields_ the value.
+
+First, we initialize the generator function with `i` equal to `10`. We invoke the generator function using the `next()` method. The first time we invoke the generator function, `i` is equal to `10`. It encounters the first `yield` keyword: it yields the value of `i`. The generator is now "paused", and `10` gets logged.
+
+Then, we invoke the function again with the `next()` method. It starts to continue where it stopped previously, still with `i` equal to `10`. Now, it encounters the next `yield` keyword, and yields `i * 2`. `i` is equal to `10`, so it returns `10 * 2`, which is `20`. This results in `10, 20`.
+
+
+
+
+---
+
+###### 45. What does this return?
+
+```javascript
+const firstPromise = new Promise((res, rej) => {
+ setTimeout(res, 500, "one");
+});
+
+const secondPromise = new Promise((res, rej) => {
+ setTimeout(res, 100, "two");
+});
+
+Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
+```
+
+- A: `"one"`
+- B: `"two"`
+- C: `"two" "one"`
+- D: `"one" "two"`
+
+Answer
+
+
+#### Answer: B
+
+When we pass multiple promises to the `Promice.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged.
+
+
+
+
+---
+
+###### 46. What's the output?
+
+```javascript
+let person = { name: "Lydia" };
+const members = [person];
+person = null;
+
+console.log(members);
+```
+
+- A: `null`
+- B: `[null]`
+- C: `[{}]`
+- D: `[{ name: "Lydia" }]`
+
+Answer
+
+
+#### Answer: D
+
+First, we declare a variable `person` with the value of an object that has a `name` property.
+
+
+
+Then, we declare a variable called `members`. We set the first element of that array equal to the value of the `person` variable. Objects interact by _reference_ when setting them equal to each other. When you assign a reference from one variable to another, you make a _copy_ of that reference. (note that they don't have the _same_ reference!)
+
+
+
+Then, we set the variable `person` equal to `null`.
+
+
+
+We are only modifying the value of the `person` variable, and not the first element in the array, since that element has a different (copied) reference to the object. The first element in `members` still holds its reference to the original object. When we log the `members` array, the first element still holds the value of the object, which gets logged.
+
+
+
+
+---
+
+###### 47. What's the output?
+
+```javascript
+const person = {
+ name: "Lydia",
+ age: 21
+};
+
+for (const item in person) {
+ console.log(item);
+}
+```
+
+- A: `{ name: "Lydia" }, { age: 21 }`
+- B: `"name", "age"`
+- C: `"Lydia", 21`
+- D: `["name", "Lydia"], ["age", 21]`
+
+Answer
+
+
+#### Answer: B
+
+With a `for-in` loop, we can iterate through object keys, in this case `name` and `age`. Under the hood, object keys are strings (if they're not a Symbol). On every loop, we set the value of `item`equal to the current key it’s iterating over. First, `item` is equal to `name`, and gets logged. Then, `item` is equal to `age`, which gets logged.
+
+
+
+
+---
+
+###### 48. What's the output?
+
+```javascript
+console.log(3 + 4 + "5");
+```
+
+- A: `"345"`
+- B: `"75"`
+- C: `12`
+- D: `"12"`
+
+Answer
+
+
+#### Answer: B
+
+Operator associativity is the order in which the compiler evaluates the expressions, either left-to-right or right-to-left. This only happens if all operators have the _same_ precedence. We only have one type of operator: `+`. For addition, the associativity is left-to-right.
+
+`3 + 4` gets evaluated first. This results in the number `7`.
+
+`7 + '5'` results in `"75"` because of coercion. JavaScript converts the number `7` into a string, see question 15. We can concatenate two strings using the `+`operator. `"7" + "5"` results in `"75"`.
+
+
+
+
+---
+
+###### 49. What's the value of `num`?
+
+```javascript
+const num = parseInt("7*6", 10);
+```
+
+- A: `42`
+- B: `"42"`
+- C: `7`
+- D: `NaN`
+
+Answer
+
+
+#### Answer: C
+
+Only the first numbers in the string is returned. Based on the _radix_ (the second argument in order to specify what type of number we want to parse it to: base 10, hexadecimal, octal, binary, etc.), the `parseInt` checks whether the characters in the string are valid. Once it encounters a character that isn't a valid number in the radix, it stops parsing and ignores the following characters.
+
+`*` is not a valid number. It only parses `"7"` into the decimal `7`. `num` now holds the value of `7`.
+
+
+
+
+---
+
+###### 50. What's the output`?
+
+```javascript
+[1, 2, 3].map(num => {
+ if (typeof num === "number") return;
+ return num * 2;
+});
+```
+
+- A: `[]`
+- B: `[null, null, null]`
+- C: `[undefined, undefined, undefined]`
+- D: `[ 3 x empty ]`
+
+Answer
+
+
+#### Answer: C
+
+When mapping over the array, the value of `num` is equal to the element it’s currently looping over. In this case, the elements are numbers, so the condition of the if statement `typeof num === "number"` returns `true`. The map function creates a new array and inserts the values returned from the function.
+
+However, we don’t return a value. When we don’t return a value from the function, the function returns `undefined`. For every element in the array, the function block gets called, so for each element we return `undefined`.
+
+
+
+
+---
+
+###### 51. What's the output?
+
+```javascript
+function getInfo(member, year) {
+ member.name = "Lydia";
+ year = 1998;
+}
+
+const person = { name: "Sarah" };
+const birthYear = "1997";
+
+getInfo(person, birthYear);
+
+console.log(person, birthYear);
+```
+
+- A: `{ name: "Lydia" }, "1997"`
+- B: `{ name: "Sarah" }, "1998"`
+- C: `{ name: "Lydia" }, "1998"`
+- D: `{ name: "Sarah" }, "1997"`
+
+Answer
+
+
+#### Answer: A
+
+Arguments are passed by _value_, unless their value is an object, then they're passed by _reference_. `birthYear` is passed by value, since it's a string, not an object. When we pass arguments by value, a _copy_ of that value is created (see question 46).
+
+The variable `birthYear` has a reference to the value `"1997"`. The argument `year` also has a reference to the value `"1997"`, but it's not the same value as `birthYear` has a reference to. When we update the value of `year` by setting `year` equal to `"1998"`, we are only updating the value of `year`. `birthYear` is still equal to `"1997"`.
+
+The value of `person` is an object. The argument `member` has a (copied) reference to the _same_ object. When we modify a property of the object `member` has a reference to, the value of `person` will also be modified, since they both have a reference to the same object. `person`'s `name` property is now equal to the value `"Lydia"`
+
+
+
+
+---
+
+###### 52. What's the output?
+
+```javascript
+function greeting() {
+ throw "Hello world!";
+}
+
+function sayHi() {
+ try {
+ const data = greeting();
+ console.log("It worked!", data);
+ } catch (e) {
+ console.log("Oh no an error!", e);
+ }
+}
+
+sayHi();
+```
+
+- A: `"It worked! Hello world!"`
+- B: `"Oh no an error: undefined`
+- C: `SyntaxError: can only throw Error objects`
+- D: `"Oh no an error: Hello world!`
+
+Answer
+
+
+#### Answer: D
+
+With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world'`.
+
+With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world'`. `e` is now equal to that string, which we log. This results in `'Oh an error: Hello world'`.
+
+
+
+
+---
+
+###### 53. What's the output?
+
+```javascript
+function Car() {
+ this.make = "Lamborghini";
+ return { make: "Maserati" };
+}
+
+const myCar = new Car();
+console.log(myCar.make);
+```
+
+- A: `"Lamborghini"`
+- B: `"Maserati"`
+- C: `ReferenceError`
+- D: `TypeError`
+
+Answer
+
+
+#### Answer: B
+
+When you return a property, the value of the property is equal to the _returned_ value, not the value set in the constructor function. We return the string `"Maserati"`, so `myCar.make` is equal to `"Maserati"`.
+
+
+
+
+---
+
+###### 54. What's the output?
+
+```javascript
+(() => {
+ let x = (y = 10);
+})();
+
+console.log(typeof x);
+console.log(typeof y);
+```
+
+- A: `"undefined", "number"`
+- B: `"number", "number"`
+- C: `"object", "number"`
+- D: `"number", "undefined"`
+
+Answer
+
+
+#### Answer: A
+
+`let x = y = 10;` is actually shorthand for:
+
+```javascript
+y = 10;
+let x = y;
+```
+
+When we set `y` equal to `10`, we actually add a property `y` to the global object (`window` in browser, `global` in Node). In a browser, `window.y` is now equal to `10`.
+
+Then, we declare a variable `x` with the value of `y`, which is `10`. Variables declared with the `let` keyword are _block scoped_, they are only defined within the block they're declared in; the immediately-invoked function (IIFE) in this case. When we use the `typeof` operator, the operand `x` is not defined: we are trying to access `x` outside of the block it's declared in. This means that `x` is not defined. Values who haven't been assigned a value or declared are of type `"undefined"`. `console.log(typeof x)` returns `"undefined"`.
+
+However, we created a global variable `y` when setting `y` equal to `10`. This value is accessible anywhere in our code. `y` is defined, and holds a value of type `"number"`. `console.log(typeof y)` returns `"number"`.
+
+
+
From a464c5d14bb7d9647debe64e67ad4d641d358fa8 Mon Sep 17 00:00:00 2001
From: Lydia Hallie
Date: Fri, 21 Jun 2019 17:10:48 +0200
Subject: [PATCH 055/881] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index b8983ce6..92badcf8 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
I post daily multiple choice JavaScript questions on my [Instagram](https://www.instagram.com/theavocoder), which I'll also post here!
-From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle: :rocket: I update this repo weekly with new questions.
+From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle: :rocket: I update this repo weekly with new questions. Last update: June 21st
The answers are in the collapsed sections below the questions, simply click on them to expand it. Good luck :heart:
From 2e3995416ced1ad9c32934f35417fca7dff30df7 Mon Sep 17 00:00:00 2001
From: panicdragon
Date: Sat, 22 Jun 2019 00:45:05 +0900
Subject: [PATCH 056/881] add README.md to ja link
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 916fa133..c8aa7747 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ The answers are in the collapsed sections below the questions, simply click on t
[Western Balkan](./README-bs_BS.md)
[Deutsch](./README-de_DE.md)
[Tiếng Việt](./README-vi.md)
-
+[日本語](./README-ja_JA.md)
---
From dbd9b91a5a8d16ae9abb6d90be0b3c0fad15367f Mon Sep 17 00:00:00 2001
From: Jacob Herper
Date: Fri, 21 Jun 2019 20:07:19 +0100
Subject: [PATCH 057/881] German updated with new questions
+ Links to all new languages added
---
README-de_DE.md | 645 +++++++++++++++++++++++++++++++++++++-----------
1 file changed, 502 insertions(+), 143 deletions(-)
diff --git a/README-de_DE.md b/README-de_DE.md
index ae3f4ded..190371a2 100644
--- a/README-de_DE.md
+++ b/README-de_DE.md
@@ -2,15 +2,17 @@
Täglich poste ich mehrere Multiple-Choice-Fragen über JavaScript auf meinem [Instagram](https://www.instagram.com/theavocoder), die ich nun auch hier veröffentlichen werde.
-Von einfach bis fortgeschritten: teste wie gut du JavaScript kennst, frische dein Wissen auf oder bereite dich auf ein Vorstellungsgespräch vor! :muscle: :rocket: Ich werde dieses Repo wöchentlich mit neuen Fragen aktualisieren.
+Von einfach bis fortgeschritten: teste wie gut du JavaScript kennst, frische dein Wissen auf oder bereite dich auf ein Vorstellungsgespräch vor! :muscle: :rocket: Ich werde dieses Repo wöchentlich mit neuen Fragen erweitern.
-Die Antworten sind unterhalb der Fragen versteckt. Du kannst einfach auf den Pfeil klicken um die Antworten zu sehen. Viel Glück :heart:
+Die Antworten sind unterhalb der Fragen versteckt. Du kannst einfach darauf klicken um die Antworten anzuzeigen. Viel Glück :heart:
[English](./README.md)
-[中文版本](./README-zh_CN.md)
+[Bosanski Jezik](./README-bs_BS.md)
+[日本語](./README-ja_JA.md)
[Русский](./README_ru-RU.md)
-[Western Balkan](./README-bs.md)
-[Українська мова](./README-ua_UA.md)
+[Українська мова](./README-ua_UA.md)
+[Tiếng Việt](./README-vi.md)
+[中文版本](./README-zh_CN.md)
---
@@ -18,13 +20,13 @@ Die Antworten sind unterhalb der Fragen versteckt. Du kannst einfach auf den Pfe
```javascript
function sayHi() {
- console.log(name)
- console.log(age)
- var name = "Lydia"
- let age = 21
+ console.log(name);
+ console.log(age);
+ var name = "Lydia";
+ let age = 21;
}
-sayHi()
+sayHi();
```
- A: `Lydia` und `undefined`
@@ -37,9 +39,9 @@ sayHi()
#### Antwort: D
-Innerhalb der Funktion wird zuerst der `name` mit dem `var` Keyword gesetzt. Das bedeutet, dass die Variable mit dem Standardwert `undefined` gehoisted wird (Speicherplatz wird während der Erstellung bereitgestellt), bis zu der Zeile, wo wir die Variable definieren. Da wir die Variable auf der Zeile, wo wir den `name` loggen noch nicht gesetzt haben, ist dieser noch `undefined`.
+Innerhalb der Funktion wird zuerst der `name` mit dem `var` Keyword gesetzt. Das bedeuted, dass die Variable mit dem Standardwert `undefined` gehoisted wird (Speicher wird während der Erstellung bereitgestellt), bis zu der Zeile, wo wir die Variable definieren. Da wir die Variable auf der Zeile, wo wir den `name` loggen noch nicht gesetzt haben, ist dieser noch `undefined`.
-Variablen mit dem `let` (oder `const`) Keyword werden ebenfalls gehoisted, aber im Gegensatz zu `var` werden diese nicht initialisiert. Auf sie können wir daher nicht zugreifen, bevor sie definiert worden sind. JavaScript wirft einen `ReferenceError`.
+Variablen mit dem `let` (oder `const`) Keyword werden ebenfalls gehoisted, aber im Gegensatz zu `var` werden diese nicht initialisiert. Auf sie können wir daher nicht zugreifen, bevor sie definiert wurden. JavaScript wirft einen `ReferenceError` aus.
@@ -50,11 +52,11 @@ Variablen mit dem `let` (oder `const`) Keyword werden ebenfalls gehoisted, aber
```javascript
for (var i = 0; i < 3; i++) {
- setTimeout(() => console.log(i), 1)
+ setTimeout(() => console.log(i), 1);
}
for (let i = 0; i < 3; i++) {
- setTimeout(() => console.log(i), 1)
+ setTimeout(() => console.log(i), 1);
}
```
@@ -82,13 +84,13 @@ In der zweiten Schleife wurde die Variable `i` mit dem `let` Keyword definiert:
const shape = {
radius: 10,
diameter() {
- return this.radius * 2
+ return this.radius * 2;
},
perimeter: () => 2 * Math.PI * this.radius,
-}
+};
-shape.diameter()
-shape.perimeter()
+shape.diameter();
+shape.perimeter();
```
- A: `20` und `62.83185307179586`
@@ -115,8 +117,8 @@ Es gibt keinen Wert `radius` in dem Object, daher wird `undefined` zurückgegebe
###### 4. Was ist der Output?
```javascript
-;+true
-!"Lydia"
++true;
+!"Lydia";
```
- A: `1` und `false`
@@ -142,12 +144,12 @@ Der String `'Lydia'` ist truthy. Was wir eigentlich fragen ist: "ist dieser trut
```javascript
const bird = {
size: "small",
-}
+};
const mouse = {
name: "Mickey",
small: true,
-}
+};
```
- A: `mouse.bird.size` ist nicht korrekt
@@ -173,16 +175,15 @@ Mit der Dot Notation ist das nicht der Fall. `mouse` hat keinen Key namens `bird
---
-
###### 6. Was ist der Output?
```javascript
-let c = { greeting: "Hey!" }
-let d
+let c = { greeting: "Hey!" };
+let d;
-d = c
-c.greeting = "Hello"
-console.log(d.greeting)
+d = c;
+c.greeting = "Hello";
+console.log(d.greeting);
```
- A: `Hello`
@@ -212,13 +213,13 @@ Wenn ein Object geändert wird, werden alle Referenzen zu diesem Object ebenfall
###### 7. Was ist der Output?
```javascript
-let a = 3
-let b = new Number(3)
-let c = 3
+let a = 3;
+let b = new Number(3);
+let c = 3;
-console.log(a == b)
-console.log(a === b)
-console.log(b === c)
+console.log(a == b);
+console.log(a === b);
+console.log(b === c);
```
- A: `true` `false` `true`
@@ -247,17 +248,17 @@ Wenn wir aber `===` nutzen müssen sowohl der Wert _als auch_ der Typ übereinst
```javascript
class Chameleon {
static colorChange(newColor) {
- this.newColor = newColor
- return this.newColor
+ this.newColor = newColor;
+ return this.newColor;
}
constructor({ newColor = "green" } = {}) {
- this.newColor = newColor
+ this.newColor = newColor;
}
}
-const freddie = new Chameleon({ newColor: "purple" })
-freddie.colorChange("orange")
+const freddie = new Chameleon({ newColor: "purple" });
+freddie.colorChange("orange");
```
- A: `orange`
@@ -280,9 +281,9 @@ Die `colorChange` Funktion ist statisch (`static`). Statische Methoden existiere
###### 9. Was ist der Output?
```javascript
-let greeting
-greetign = {} // Typo!
-console.log(greetign)
+let greeting;
+greetign = {}; // Typo!
+console.log(greetign);
```
- A: `{}`
@@ -307,10 +308,10 @@ Um das zu verhindern, können wir `"use strict"` verwenden. Das stellt sicher, d
```javascript
function bark() {
- console.log("Woof!")
+ console.log("Woof!");
}
-bark.animal = "dog"
+bark.animal = "dog";
```
- A: Nichts, das ist absolut in Ordnung.
@@ -336,16 +337,16 @@ Eine Funktion ist ein spezieller Typ eines Objekts. Der Code, den wir schreiben
```javascript
function Person(firstName, lastName) {
- this.firstName = firstName
- this.lastName = lastName
+ this.firstName = firstName;
+ this.lastName = lastName;
}
-const member = new Person("Lydia", "Hallie")
+const member = new Person("Lydia", "Hallie");
Person.getFullName = function() {
- return `${this.firstName} ${this.lastName}`
-}
+ return `${this.firstName} ${this.lastName}`;
+};
-console.log(member.getFullName())
+console.log(member.getFullName());
```
- A: `TypeError`
@@ -362,8 +363,8 @@ Man kann keine Properties einem Constructor zuweisen, wie es bei normalen Object
```js
Person.prototype.getFullName = function() {
- return `${this.firstName} ${this.lastName}`
-}
+ return `${this.firstName} ${this.lastName}`;
+};
```
So hätte `member.getFullName()` funktioniert. Warum ist das von Vorteil? Sagen wir, wir hätten diese Methode dem Constructor selbst zugewiesen, aber vielleicht benötigt nicht jede Instanz von `Person` diese Methode. So hätte das eine Menge Arbeitsspeicher verschwendet, weil jede Instanz die Property zugewiesen bekommt, auch wenn sie diese gar nicht benötigt.
@@ -378,15 +379,15 @@ Stattdessen haben wir sie nur dem Prototype zugewiesen, sodass sie nur an einer
```javascript
function Person(firstName, lastName) {
- this.firstName = firstName
- this.lastName = lastName
+ this.firstName = firstName;
+ this.lastName = lastName;
}
-const lydia = new Person("Lydia", "Hallie")
-const sarah = Person("Sarah", "Smith")
+const lydia = new Person("Lydia", "Hallie");
+const sarah = Person("Sarah", "Smith");
-console.log(lydia)
-console.log(sarah)
+console.log(lydia);
+console.log(sarah);
```
- A: `Person {firstName: "Lydia", lastName: "Hallie"}` und `undefined`
@@ -450,10 +451,10 @@ Alle Objekte haben Prototypes, außer dem **Basis Objekt**. Das Basis Objekt hat
```javascript
function sum(a, b) {
- return a + b
+ return a + b;
}
-sum(1, "2")
+sum(1, "2");
```
- A: `NaN`
@@ -478,10 +479,10 @@ In diesem Beispiel wandelt JavaScript die Nummer `1` in einem String um, sodass
###### 16. Was ist der Output?
```javascript
-let number = 0
-console.log(number++)
-console.log(++number)
-console.log(number)
+let number = 0;
+console.log(number++);
+console.log(++number);
+console.log(number);
```
- A: `1` `1` `2`
@@ -515,15 +516,15 @@ Der Output ist daher `0 2 2`.
```javascript
function getPersonInfo(one, two, three) {
- console.log(one)
- console.log(two)
- console.log(three)
+ console.log(one);
+ console.log(two);
+ console.log(three);
}
-const person = "Lydia"
-const age = 21
+const person = "Lydia";
+const age = 21;
-getPersonInfo`${person} is ${age} years old`
+getPersonInfo`${person} is ${age} years old`;
```
- A: `"Lydia"` `21` `["", " is ", " years old"]`
@@ -547,15 +548,15 @@ Wenn man Template Literals verwendet ist das erste Argument immer ein Array der
```javascript
function checkAge(data) {
if (data === { age: 18 }) {
- console.log("You are an adult!")
+ console.log("You are an adult!");
} else if (data == { age: 18 }) {
- console.log("You are still an adult.")
+ console.log("You are still an adult.");
} else {
- console.log(`Hmm.. You don't have an age I guess`)
+ console.log(`Hmm.. You don't have an age I guess`);
}
}
-checkAge({ age: 18 })
+checkAge({ age: 18 });
```
- A: `You are an adult!`
@@ -582,10 +583,10 @@ Deshalb werfen sowohl `{ age: 18 } === { age: 18 }` als auch `{ age: 18 } == { a
```javascript
function getAge(...args) {
- console.log(typeof args)
+ console.log(typeof args);
}
-getAge(21)
+getAge(21);
```
- A: `"number"`
@@ -609,12 +610,12 @@ Der Spread Operator (`...args`) gibt ein Array mit Argumenten zurück. Ein Array
```javascript
function getAge() {
- "use strict"
- age = 21
- console.log(age)
+ "use strict";
+ age = 21;
+ console.log(age);
}
-getAge()
+getAge();
```
- A: `21`
@@ -637,7 +638,7 @@ Durch `"use strict"` kann man sicher stellen, dass man nicht versehentlich globa
###### 21. Was ist der Wert von `sum`?
```javascript
-const sum = eval("10*10+5")
+const sum = eval("10*10+5");
```
- A: `105`
@@ -660,7 +661,7 @@ const sum = eval("10*10+5")
###### 22. Wie lange ist cool_secret verfügbar?
```javascript
-sessionStorage.setItem("cool_secret", 123)
+sessionStorage.setItem("cool_secret", 123);
```
- A: Für immer, der Wert geht nicht verloren.
@@ -685,10 +686,10 @@ Wenn man stattdessen `localStorage` verwendet, bleibt der Wert für immer besteh
###### 23. Was ist der Output?
```javascript
-var num = 8
-var num = 10
+var num = 8;
+var num = 10;
-console.log(num)
+console.log(num);
```
- A: `8`
@@ -713,13 +714,13 @@ Das ist nicht möglich mit `let` oder `const`, da diese dem Block Scope unterlie
###### 24. Was ist der Output?
```javascript
-const obj = { 1: "a", 2: "b", 3: "c" }
-const set = new Set([1, 2, 3, 4, 5])
+const obj = { 1: "a", 2: "b", 3: "c" };
+const set = new Set([1, 2, 3, 4, 5]);
-obj.hasOwnProperty("1")
-obj.hasOwnProperty(1)
-set.has("1")
-set.has(1)
+obj.hasOwnProperty("1");
+obj.hasOwnProperty(1);
+set.has("1");
+set.has(1);
```
- A: `false` `true` `false` `true`
@@ -744,8 +745,8 @@ Das funktioniert nicht für Set. Da wir keine `'1'` in unserem Set haben wirft `
###### 25. Was ist der Output?
```javascript
-const obj = { a: "one", b: "two", a: "three" }
-console.log(obj)
+const obj = { a: "one", b: "two", a: "three" };
+console.log(obj);
```
- A: `{ a: "one", b: "two" }`
@@ -787,8 +788,8 @@ Der Base Execution Context entspricht dem Global Execution Context und ist über
```javascript
for (let i = 1; i < 5; i++) {
- if (i === 3) continue
- console.log(i)
+ if (i === 3) continue;
+ console.log(i);
}
```
@@ -813,12 +814,12 @@ for (let i = 1; i < 5; i++) {
```javascript
String.prototype.giveLydiaPizza = () => {
- return "Just give Lydia pizza already!"
-}
+ return "Just give Lydia pizza already!";
+};
-const name = "Lydia"
+const name = "Lydia";
-name.giveLydiaPizza()
+name.giveLydiaPizza();
```
- A: `"Just give Lydia pizza already!"`
@@ -841,14 +842,14 @@ name.giveLydiaPizza()
###### 29. Was ist der Output?
```javascript
-const a = {}
-const b = { key: "b" }
-const c = { key: "c" }
+const a = {};
+const b = { key: "b" };
+const c = { key: "c" };
-a[b] = 123
-a[c] = 456
+a[b] = 123;
+a[c] = 456;
-console.log(a[b])
+console.log(a[b]);
```
- A: `123`
@@ -875,13 +876,13 @@ Dann loggen wir `a[b]`, was eigentlich `a["Object object"]` ist und gerade von u
###### 30. Was ist der Output?
```javascript
-const foo = () => console.log("First")
-const bar = () => setTimeout(() => console.log("Second"))
-const baz = () => console.log("Third")
+const foo = () => console.log("First");
+const bar = () => setTimeout(() => console.log("Second"));
+const baz = () => console.log("Third");
-bar()
-foo()
-baz()
+bar();
+foo();
+baz();
```
- A: `First` `Second` `Third`
@@ -984,14 +985,14 @@ Wenn wir auf den Paragraph klicken, sehen wir zwei logs: `p` und `div`. Während
###### 33. Was ist der Output?
```javascript
-const person = { name: "Lydia" }
+const person = { name: "Lydia" };
function sayHi(age) {
- console.log(`${this.name} is ${age}`)
+ console.log(`${this.name} is ${age}`);
}
-sayHi.call(person, 21)
-sayHi.bind(person, 21)
+sayHi.call(person, 21);
+sayHi.bind(person, 21);
```
- A: `undefined is 21` `Lydia is 21`
@@ -1017,10 +1018,10 @@ In beiden Fällen können wir das Objekt weiter reichen, auf welches sich das `t
```javascript
function sayHi() {
- return (() => 0)()
+ return (() => 0)();
}
-typeof sayHi()
+typeof sayHi();
```
- A: `"object"`
@@ -1045,12 +1046,12 @@ Es gibt nur 7 eingebaute Typen in JavaScript: `null`, `undefined`, `boolean`, `n
###### 35. Welcher dieser Werte ist falsy?
```javascript
-0
-new Number(0)
-;("")
-;(" ")
-new Boolean(false)
-undefined
+0;
+new Number(0);
+("");
+(" ");
+new Boolean(false);
+undefined;
```
- A: `0`, `''`, `undefined`
@@ -1082,7 +1083,7 @@ Funktions-Constructor, wie `new Number` und `new Boolean` sind truthy.
###### 36. Was ist der Output?
```javascript
-console.log(typeof typeof 1)
+console.log(typeof typeof 1);
```
- A: `"number"`
@@ -1106,9 +1107,9 @@ console.log(typeof typeof 1)
###### 37. Was ist der Output?
```javascript
-const numbers = [1, 2, 3]
-numbers[10] = 11
-console.log(numbers)
+const numbers = [1, 2, 3];
+numbers[10] = 11;
+console.log(numbers);
```
- A: `[1, 2, 3, 7 x null, 11]`
@@ -1135,17 +1136,17 @@ abhängig davon wo das Array ausgeführt wird (die Ausgabe ist unterschiedlich f
###### 38. Was ist der Output?
```javascript
-;(() => {
- let x, y
+(() => {
+ let x, y;
try {
- throw new Error()
+ throw new Error();
} catch (x) {
- ;(x = 1), (y = 2)
- console.log(x)
+ (x = 1), (y = 2);
+ console.log(x);
}
- console.log(x)
- console.log(y)
-})()
+ console.log(x);
+ console.log(y);
+})();
```
- A: `1` `undefined` `2`
@@ -1195,12 +1196,12 @@ Was einen primitiven Typ von einem Objekt unterscheidet ist, dass Primitive kein
###### 40. Was ist der Output?
```javascript
-;[[0, 1], [2, 3]].reduce(
+[[0, 1], [2, 3]].reduce(
(acc, cur) => {
- return acc.concat(cur)
+ return acc.concat(cur);
},
[1, 2],
-)
+);
```
- A: `[0, 1, 2, 3, 1, 2]`
@@ -1225,9 +1226,9 @@ Dann entspricht `acc` gleich `[1, 2, 0, 1]` und `cur` ist gleich `[2, 3]`. Wir v
###### 41. Was ist der Output?
```javascript
-!!null
-!!""
-!!1
+!!null;
+!!"";
+!!1;
```
- A: `false` `true` `false`
@@ -1254,7 +1255,7 @@ Dann entspricht `acc` gleich `[1, 2, 0, 1]` und `cur` ist gleich `[2, 3]`. Wir v
###### 42. Was gibt die `setInterval` Method zurück?
```javascript
-setInterval(() => console.log("Hi"), 1000)
+setInterval(() => console.log("Hi"), 1000);
```
- A: Eine unique id
@@ -1277,7 +1278,7 @@ Es gibt eine unique id zurück. Diese id kann zum Beispiel verwendet werden um d
###### 43. Was wird hier ausgegeben?
```javascript
-;[..."Lydia"]
+[..."Lydia"];
```
- A: `["L", "y", "d", "i", "a"]`
@@ -1294,3 +1295,361 @@ Ein String ist ein Iterable. Der Spread Operator mappt jedes Zeichen eines Itera
+
+---
+
+###### 44. Was ist der Output?
+
+```javascript
+function* generator(i) {
+ yield i;
+ yield i * 2;
+}
+
+const gen = generator(10);
+
+console.log(gen.next().value);
+console.log(gen.next().value);
+```
+
+- A: `[0, 10], [10, 20]`
+- B: `20, 20`
+- C: `10, 20`
+- D: `0, 10 and 10, 20`
+
+Antwort
+
+
+#### Antwort: C
+
+Reguläre Funktionen können nicht angehalten werden, wenn sie bereits aufgerufen wurden. Eine Generator Funktion kann dagegen auch angehalten werden, nachdem sie aufgerufen wurde und später fortgesetzt werden, wo sie angehalten wurde. Jedes Mal, wenn eine Generator Funktion ein `yield` Keyword findet, wirft die Funktion den danach ermittelten Wert aus. Wichtig: _yield_ ist nichtdas selbe wie _return_.
+
+Zuerst initialisieren wir die Generator Funktion mit `i` gleich `10`. Wir rufen die Generator Funktion mit der `next()` Methode auf. Beim ersten Aufruf der Generator Funktion is `i` gleich `10`. Wenn wir bei `yield` ankommen wird der Wert von `i` ausgegeben. Der Generator wird angehalten und `10` wird geloggt.
+
+Dann wird die Funktion erneut mit der `next()` Methode aufgerufen und beginnt von dort, wo sie zuletzt angehalten wurde, nach wie vor mit `i` gleich `10`. Jetzt erreichen wir das nächste `yield` Keyword bei `i * 2`. `i` ist gleich `10`, sodass das Ergebnis von `10 * 2` ausgegeben wird, was `20` ist. Das Ergebnis ist `10, 20`.
+
+
+
+
+---
+
+###### 45. Was wird hier ausgegeben?
+
+```javascript
+const firstPromise = new Promise((res, rej) => {
+ setTimeout(res, 500, "one");
+});
+
+const secondPromise = new Promise((res, rej) => {
+ setTimeout(res, 100, "two");
+});
+
+Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
+```
+
+- A: `"one"`
+- B: `"two"`
+- C: `"two" "one"`
+- D: `"one" "two"`
+
+Antwort
+
+
+#### Antwort: B
+
+Wenn wir mehrere Promises in die `Promice.race` Methode eingegeben, wird das Promise, welches _zuerst_ gelöst/abgelehnt wird auch hier gelöst/abgelehnt. Die `setTimeout` Methode bekommt einen Timer von 500ms für das erste Promise (`firstPromise`) übergeben, und 100ms für das zweite Promise (`secondPromise`). Das bedeutet, dass `secondPromise` mit dem Wert `'two'` zuerst gelöst wird und an `res` übergeben wird. Der Wert wird geloggt.
+
+
+
+
+---
+
+###### 46. Was ist der Output?
+
+```javascript
+let person = { name: "Lydia" };
+const members = [person];
+person = null;
+
+console.log(members);
+```
+
+- A: `null`
+- B: `[null]`
+- C: `[{}]`
+- D: `[{ name: "Lydia" }]`
+
+Antwort
+
+
+#### Antwort: D
+
+Zuerst definieren wir die Variable `person` mit dem Wert eines Objekts, welches eine `name` Property hat.
+
+
+
+Dann definieren wir eine Variable namens `members`. Wir setzen das erste Element des Arrays gleich dem Wert der `person` Variable. Objekte interagieren durch eine _Referenz_, wenn diese gleichgesetzt werden. Wenn eine Referenz von einer Variable zur anderen gleichgesetzt wird, so wird eine _Kopie_ der Referenz erstellt (Wichtig: nicht die _selbe_ Referenz!)
+
+
+
+Dann setzen wir die Variable `person` gleich `null`.
+
+
+
+Wir ändern nur den Wert der Variable `person` und nicht das erste Element im Array, da das Element eine andere Referenz als das Objekt hat (Kopie). Das erste Element in `members` beinhaltet immernoch die Referenz zum original Objekt. Wenn wir das `members` Array loggen ist dieses immernoch der Wert des Objekts, welches dann geloggt wird.
+
+
+
+
+---
+
+###### 47. Was ist der Output?
+
+```javascript
+const person = {
+ name: "Lydia",
+ age: 21
+};
+
+for (const item in person) {
+ console.log(item);
+}
+```
+
+- A: `{ name: "Lydia" }, { age: 21 }`
+- B: `"name", "age"`
+- C: `"Lydia", 21`
+- D: `["name", "Lydia"], ["age", 21]`
+
+Antwort
+
+
+#### Antwort: B
+
+Mit einer `for-in` Schleife können wir über Objekt Keys iterieren - in diesem Fall `name` und `age`. Im Endeffekt sind Objekt Keys Strings (oder Symbols). Bei jedem Durchlauf setzen wir den Wert von `item` gleich zum aktuellen Key. Zuerst ist `item` gleich `name` und wird geloggt. Dann wird `item` gleich `age` gesetzt und wird geloggt.
+
+
+
+
+---
+
+###### 48. Was ist der Output?
+
+```javascript
+console.log(3 + 4 + "5");
+```
+
+- A: `"345"`
+- B: `"75"`
+- C: `12`
+- D: `"12"`
+
+Antwort
+
+
+#### Antwort: B
+
+Operator Assoziativität ist die Reihenfolge, in der der Compiler die Expression evaluiert, entweder links-nach-rechts oder rechts-nach-links. Das funktioniert nur, wenn alle Operatoren die _gleiche_ Priorität haben. Hier haben wir nur einen Operator: `+`. Für Addition ist die Assoziativität links-nach-rechts.
+
+`3 + 4` wird zuerst errechnet, das Ergebnis ist `7`.
+
+`7 + '5'` ergibt `"75"` (aufgrund von Coercion). JavaScript wandelt `7` in einen String um (Siehe Frage 15). Zwei Strings werden durch den `+` Operator zusammengesetzt.`"7" + "5"` ergibt `"75"`.
+
+
+
+
+---
+
+###### 49. Was ist der Wert von `num`?
+
+```javascript
+const num = parseInt("7*6", 10);
+```
+
+- A: `42`
+- B: `"42"`
+- C: `7`
+- D: `NaN`
+
+Antwort
+
+
+#### Antwort: C
+
+Nur die erste Zahl im String wird ausgegeben. Aufgrund des _radix_ (das zweite Argument definiert, welchen Typ einer Zahl wir parsen wollen: Basis 10, hexadezimal, Octal, Binary, etc.) prüft `parseInt` ob die Zeichen im String gültig sind. Wenn ein Zeichen erkannt wird, welches nicht gültig ist, wird der Parse Vorgang beendet und die nachfolgenden Zeichen werden ignoriert.
+
+`*` ist keine gültige Nummer, sodass nur `"7"` als Dezimal geparsed wird: `7`. `num` ist jetzt gleich `7`.
+
+
+
+
+---
+
+###### 50. Was ist der Output?
+
+```javascript
+[1, 2, 3].map(num => {
+ if (typeof num === "number") return;
+ return num * 2;
+});
+```
+
+- A: `[]`
+- B: `[null, null, null]`
+- C: `[undefined, undefined, undefined]`
+- D: `[ 3 x empty ]`
+
+Antwort
+
+
+#### Antwort: C
+
+Wenn man über das Array mappt, ist `num` gleich dem Element, welches gerade durchlaufen wird. In diesem Fall sind die Elemente Nummern, sodass die Kondition der If-Schleife `typeof num === "number"` erfüllt ist und `true` zurück gibt. Die map Funktion erstellt ein neues Array und beinhaltet die Werte der Funktion.
+
+Allerdings geben wir keinen Wert aus. Wenn unsere Funktion keinen Wert ausgibt, ist der Standard "return" `undefined`. Für jedes Element im Array wird die Funktion aufgerufen, sodass für jedes Element `undefined` ausgegeben wird.
+
+
+
+
+---
+
+###### 51. Was ist der Output?
+
+```javascript
+function getInfo(member, year) {
+ member.name = "Lydia";
+ year = 1998;
+}
+
+const person = { name: "Sarah" };
+const birthYear = "1997";
+
+getInfo(person, birthYear);
+
+console.log(person, birthYear);
+```
+
+- A: `{ name: "Lydia" }, "1997"`
+- B: `{ name: "Sarah" }, "1998"`
+- C: `{ name: "Lydia" }, "1998"`
+- D: `{ name: "Sarah" }, "1997"`
+
+Antwort
+
+
+#### Antwort: A
+
+Argumente werden als _Wert_ übergeben, es sei denn ihr Wert ist ein Objekt, dann werden sie als _Referenz_ übergeben. `birthYear` wird als Wert übergeben, da es ein String ist und kein Objekt. Wenn Argumente als Wert übergeben werden, wird eine _Kopie_ des Wertes erstellt (Siehe Frage 46).
+
+Die Variable `birthYear` beinhaltet eine Referenz zum Wert `"1997"`. Das Argument `year` beinhaltet ebenso eine Referenz zum Wert `"1997"`, aber die Werte sind nicht identisch! Wenn wir den Wert von `year` ändern, indem wir ihn gleich `"1998"` setzen, ändern wir nur den Wert von `year`. `birthYear` ist immernoch `"1997"`.
+
+Der Wert von `person` ist ein Objekt, sodass das Argument `member` eine Kopie der Referenz des _gleichen_ Objekts hat. Wenn wir also eine Property dessen Objekt `member` eine Referenz enthält, wird der Wert von `person` ebenso geändert, da beide die gleiche Referenz zum selben Objekt beinhalten. Die Property `name` von `person` ist jetzt gleich `"Lydia"`.
+
+
+
+
+---
+
+###### 52. Was ist der Output?
+
+```javascript
+function greeting() {
+ throw "Hello world!";
+}
+
+function sayHi() {
+ try {
+ const data = greeting();
+ console.log("It worked!", data);
+ } catch (e) {
+ console.log("Oh no an error!", e);
+ }
+}
+
+sayHi();
+```
+
+- A: `"It worked! Hello world!"`
+- B: `"Oh no an error: undefined`
+- C: `SyntaxError: can only throw Error objects`
+- D: `"Oh no an error: Hello world!`
+
+Antwort
+
+
+#### Antwort: D
+
+Mit dem `throw` Statement können wir individuelle Fehlermeldungen erstellen und Exceptions erstellen. Eine Exception kann ein String, eine Nummer, ein Boolean oder ein Objekt sein. In diesem Fall ist unsere Exception der String `'Hello world'`.
+
+Mit dem `catch` Statement können wir definieren, was passiert, wenn die Exception im `try` Block eintritt. Wenn die Exception eintritt wird der String `'Hello world'` ausgegeben. Nun loggen wir `e`, was gleich dem String ist. Das Ergebnis ist `'Oh an error: Hello world'`.
+
+
+
+
+---
+
+###### 53. Was ist der Output?
+
+```javascript
+function Car() {
+ this.make = "Lamborghini";
+ return { make: "Maserati" };
+}
+
+const myCar = new Car();
+console.log(myCar.make);
+```
+
+- A: `"Lamborghini"`
+- B: `"Maserati"`
+- C: `ReferenceError`
+- D: `TypeError`
+
+Antwort
+
+
+#### Antwort: B
+
+Wenn man eine Property ausgibt ist der Wert der Property gleich dem ausgegeben Wert und nicht dem Wert, der im Constructor definiert wurde. Wir geben den String `"Maserati"` aus, sodass `myCar.make` gleich `"Maserati"` ist.
+
+
+
+
+---
+
+###### 54. Was ist der Output?
+
+```javascript
+(() => {
+ let x = (y = 10);
+})();
+
+console.log(typeof x);
+console.log(typeof y);
+```
+
+- A: `"undefined", "number"`
+- B: `"number", "number"`
+- C: `"object", "number"`
+- D: `"number", "undefined"`
+
+Antwort
+
+
+#### Antwort: A
+
+`let x = y = 10;` ist kurz für:
+
+```javascript
+y = 10;
+let x = y;
+```
+
+Wenn wir `y` gleich `10` setzen, erstellen wir eigentlich eine Property `y` im globalen Objekt (`window` im Browser oder `global` in Node). Im Browser ist jetzt `window.y` gleich `10`.
+
+Dann erstellen wir eine Variable `x` mit dem Wert von `y` (`10`). Variablen, die mit `let` erstellt werden sind _Block-Scoped_, was bedeutet, dass sie nur in dem Block existieren, wo sie erstellt wurden – der hier erstellte Funktion (IIFE) in diesem Fall. Wenn wir den `typeof` Operator nutzen ist `x` nicht definiert. Wir versuchen auf `x` außerhalb des Scopes zuzugreifen, was bedeutet, dass `x` `"undefined"` ist. `console.log(typeof x)` gibt daher `"undefined"` aus.
+
+Da wir die Variable `y` aber global erstellt haben ist ihr Wert `10` auch hier verfügbar und überall in userem Code aufrufbar. `y` ist definiert und beinhaltet einen Wert vom Typ `"number"`. `console.log(typeof y)` gibt daher `"number"` aus.
+
+
+
From 33b3232d4952c4fb147f8adbc1755ae1ca791626 Mon Sep 17 00:00:00 2001
From: Lydia Hallie
Date: Fri, 21 Jun 2019 21:32:18 +0200
Subject: [PATCH 058/881] Create LICENSE
---
LICENSE | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 LICENSE
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..d63d90e5
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Lydia Hallie
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
From 9fd151e2101157aa4e5621eaa37353a74274bafb Mon Sep 17 00:00:00 2001
From: Ihor Sychevskyi <26163841+Arhell@users.noreply.github.com>
Date: Sat, 22 Jun 2019 04:00:44 +0300
Subject: [PATCH 059/881] delete unnecessary link & add new, RU
---
README_ru-RU.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index b1963664..d0dbeda4 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -6,11 +6,11 @@
Ответы находятся в свернутой секции ниже вопросов. Просто нажми на "Ответ", чтобы развернуть. Удачи! :heart:
-[中文版本](./README-zh_CN.md)
-[Русский](./README_ru-RU.md)
-[Western Balkan](./README-bs.md)
+[中文版本](./README-zh_CN.md)
+[Western Balkan](./README-bs_BS.md)
[Deutsch](./README-de_DE.md)
[Tiếng Việt](./README-vi.md)
+[日本語](./README-ja_JA.md)
[Українська мова](./README-ua_UA.md)
From 1626a96ca2db39b965492c1ca6c23c19ac9bbe21 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Sat, 22 Jun 2019 12:06:46 +0200
Subject: [PATCH 060/881] Finish translation of the first 43 questions + answer
for the 14 firsts questions in FR
---
README_fr-FR.md | 60 ++++++++++++++++++++++++-------------------------
1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 68a988a5..0eb2fb44 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -104,7 +104,7 @@ Notez que le valeur de `diameter` est une fonction régulière, alors que `perim
Avec les fonctions fléchée, le mot clé `this` réfère à son périmètre actuel, contrairement au fonctions régulières ! Cela signifie que lorsque nous appelons `perimeter`, elle ne réfère pas à l'objet shape, mais à son périmètre actuel (`window` par exemple).
-Il n'y a pas de valeur `radius` dans cet objet, qui retournera `undefined`.
+Il n'y a pas de valeur `radius` dans cet objet, on retournera `undefined`.
@@ -231,7 +231,7 @@ console.log(b === c);
#### Réponse: C
-`new Number()` est une fonction globale. Bien qu'il ressamble à un nombre, ce n'en est pas vraiment un : il a une poignée de fonctionnalités supplémentaire and est un objet.
+`new Number()` est une fonction globale. Bien qu'il ressemble à un nombre, ce n'en est pas vraiment un : il a une poignée de fonctionnalités supplémentaire and est un objet.
Quand nous utilisons l'opérateur `==`, il vérifie seulement qu'il s'agisse de la même _valeur_. Les deux ont pour valeur `3`, donc il retourne `true`.
@@ -294,9 +294,9 @@ console.log(greetign);
#### Réponse: A
-It logs the object, because we just created an empty object on the global object! When we mistyped `greeting` as `greetign`, the JS interpreter actually saw this as `global.greetign = {}` (or `window.greetign = {}` in a browser).
+Il affiche l'objet, car on a juste créé un objet vide dnas l'objet global ! Quand on écrit mal `greeting` en `greetign`, JaveScript l'interprète comme il le voit `global.greetign = {}` (ou `window.greetign = {}` dans le navigateur).
-In order to avoid this, we can use `"use strict"`. This makes sure that you have declared a variable before setting it equal to anything.
+Pour éviter cela, on peut utiliser `"use strict"`. Cela nous assure de devoir déclarer la variable avant de lui assigné une valeur.
@@ -323,9 +323,9 @@ bark.animal = "dog";
#### Réponse: A
-This is possible in JavaScript, because functions are objects! (Everything besides primitive types are objects)
+C'est possible en JavaScript, car les fonctions sont des objets ! (Tout ce qui n'est pas de type primitif est un objet)
-A function is a special type of object. The code you write yourself isn't the actual function. The function is an object with properties. This property is invocable.
+Une fonction est un type special d'objet. Le code que vous écrivez vous-même n'est pas la fonction. La fonction est un objet avec des propriétées. Cette propriétée est invocable.
@@ -358,7 +358,7 @@ console.log(member.getFullName());
#### Réponse: A
-You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all objects at once, you have to use the prototype instead. So in this case,
+Vous ne pouvez pas ajouter de propriétés à un constructeur comme pour des objets normaux. Si vous voulez ajouter une fonctionnalité pour tout les objets en une fois, vous devez utiliser le prototype. Donc dans ce cas,
```js
Person.prototype.getFullName = function() {
@@ -366,7 +366,7 @@ Person.prototype.getFullName = function() {
};
```
-would have made `member.getFullName()` work. Why is this beneficial? Say that we added this method to the constructor itself. Maybe not every `Person` instance needed this method. This would waste a lot of memory space, since they would still have that property, which takes of memory space for each instance. Instead, if we only add it to the prototype, we just have it at one spot in memory, yet they all have access to it!
+rendra fonctionnel `member.getFullName`. Pourquoi est-ce benifique ? Disons que nous ajoutons cette méthode au constructeur directement. Peut-être que toutes les instances de `Person` n'ont pas besoin de cette méthode. Cela fera perdre de l'espace mémoire, car elles auront tous cette propriété, ce qui prendra de l'espace mémoire pour chaque instance. Alors que, si nous ajoutons la méthode au prototype uniquement, nous n'utilisons qu'un seul slot mémoire, et ils y auront tous accès !
@@ -398,9 +398,9 @@ console.log(sarah);
#### Réponse: A
-For `sarah`, we didn't use the `new` keyword. When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
+Pour `sarah`, nous n'avons pas utilisé le mot clé `new`. Quand nous utilisons `new`, il fait référence à un nouvel objet vide que nous créons. Cependant so nous n'ajoutons pas `new` il réfère à **l'objet global** !
-We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smith"`. What we actually did, is defining `global.firstName = 'Sarah'` and `global.lastName = 'Smith'`. `sarah` itself is left `undefined`.
+Nous disons que `this.firstName` est égal à `"Sarah"` et que `this.lastName` est égal à `Smith`. Ce que nous faisons c'est définir `global.firstName = 'Sarah'` et `global.lastName = 'Smith'`. La variable `sarah` elle-même reste à `undefined`.
@@ -430,15 +430,15 @@ Durant la phase de **capture** _(capturing)_, l'événement passe par les évén
###### 14. Tous les objects ont des prototypes.
-- A: true
-- B: false
+- A: vrai
+- B: faux
Réponse
#### Réponse: B
-All objects have prototypes, except for the **base object**. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
+Tous les objets ont des prototypes, excepté pour les **objets standards**. Les objets standards ont accès à certaines méthodes et propriétés, comme `.toString`. C'est pour cette raison que vous pouvez utiliser les méthodes natives de JavaScript ! Toutes ces méthodes sont disponibles dans le prototype. Bien que JavaScript ne trouve pas la fonction dans l'objet, il parcours le prototype et la méthode afin de la rendre accessible.
@@ -764,7 +764,7 @@ If you have two keys with the same name, the key will be replaced. It will still
---
-###### 26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
+###### 26. Le contexte global d'exécution de JavaScript créait 2 choses pour vous : l'objet global and le mot clé `this`.
- A: Vrai
- B: Faux
@@ -924,7 +924,7 @@ This is where an event loop starts to work. An **event loop** looks at the stack
---
-###### 31. What is the event.target when clicking the button?
+###### 31. Quel est l'élément ciblé _(event.target)_ au click sur le bouton _(button)_ ?
```html
@@ -936,10 +936,10 @@ This is where an event loop starts to work. An **event loop** looks at the stack
```
-- A: Outer `div`
-- B: Inner `div`
+- A: La `div` extérieure
+- B: La `div` intérieure
- C: `button`
-- D: An array of all nested elements.
+- D: Un tableau de tous les éléments imbriqués.
Réponse
@@ -953,7 +953,7 @@ The deepest nested element that caused the event is the target of the event. You
---
-###### 32. When you click the paragraph, what's the logged output?
+###### 32. Quand vous cliquez sur le paragraphe, quelle est la sortie ?
```html
@@ -1041,7 +1041,7 @@ FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`,
---
-###### 35. Which of these values are falsy?
+###### 35. Lesquelles de ces valeurs sont fausses ?
```javascript
0;
@@ -1168,12 +1168,12 @@ Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we
---
-###### 39. Everything in JavaScript is either a...
+###### 39. Tout en JavaScript est...
-- A: primitive or object
-- B: function or object
-- C: trick question! only objects
-- D: number or object
+- A: primitif ou objet
+- B: fonction ou objet
+- C: question délicate ! Seulement des objets
+- D: nombre ou objet
Réponse
@@ -1250,15 +1250,15 @@ Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and ge
---
-###### 42. What does the `setInterval` method return?
+###### 42. Que retourne la méthode `setInterval` ?
```javascript
setInterval(() => console.log("Hi"), 1000);
```
-- A: a unique id
-- B: the amount of milliseconds specified
-- C: the passed function
+- A: un identifiant unique
+- B: le temps de millisecondes spécifié
+- C: la fonction passée en paramètre
- D: `undefined`
Réponse
@@ -1273,7 +1273,7 @@ It returns a unique id. This id can be used to clear that interval with the `cle
---
-###### 43. What does this return?
+###### 43. Que retourne ceci ?
```javascript
[..."Lydia"];
From 575d253d5b5f7635357c48cc0111c2222767b7ad Mon Sep 17 00:00:00 2001
From: Jacob Herper
Date: Sat, 22 Jun 2019 12:05:47 +0100
Subject: [PATCH 061/881] Corrected missing line breaks after some languages
---
README-de_DE.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/README-de_DE.md b/README-de_DE.md
index 190371a2..706654cb 100644
--- a/README-de_DE.md
+++ b/README-de_DE.md
@@ -6,13 +6,13 @@ Von einfach bis fortgeschritten: teste wie gut du JavaScript kennst, frische dei
Die Antworten sind unterhalb der Fragen versteckt. Du kannst einfach darauf klicken um die Antworten anzuzeigen. Viel Glück :heart:
-[English](./README.md)
-[Bosanski Jezik](./README-bs_BS.md)
-[日本語](./README-ja_JA.md)
-[Русский](./README_ru-RU.md)
-[Українська мова](./README-ua_UA.md)
-[Tiếng Việt](./README-vi.md)
-[中文版本](./README-zh_CN.md)
+[English](./README.md)
+[Bosanski Jezik](./README-bs_BS.md)
+[日本語](./README-ja_JA.md)
+[Русский](./README_ru-RU.md)
+[Українська мова](./README-ua_UA.md)
+[Tiếng Việt](./README-vi.md)
+[中文版本](./README-zh_CN.md)
---
From 4858b8b3d124dc33ab599f81b3ac946ff90d850d Mon Sep 17 00:00:00 2001
From: Gabriel Sroka
Date: Sat, 22 Jun 2019 10:12:53 -0700
Subject: [PATCH 062/881] Update README.md
fixed a few minor typos/errors. i'm not positive about the parens on Q. 54
---
README.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 3eb7e7e7..ddd3318a 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
I post daily multiple choice JavaScript questions on my [Instagram](https://www.instagram.com/theavocoder), which I'll also post here!
-From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle: :rocket: I update this repo weekly with new questions. Last update: June 21st
+From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle: :rocket: I update this repo weekly with new questions. Last update: [June 21st](#20190621)
The answers are in the collapsed sections below the questions, simply click on them to expand it. Good luck :heart:
@@ -1298,7 +1298,7 @@ A string is an iterable. The spread operator maps every character of an iterable
---
-###### 44. What's the output?
+###### 44. What's the output?
```javascript
function* generator(i) {
@@ -1485,7 +1485,7 @@ Only the first numbers in the string is returned. Based on the _radix_ (the seco
---
-###### 50. What's the output`?
+###### 50. What's the output?
```javascript
[1, 2, 3].map(num => {
@@ -1572,16 +1572,16 @@ sayHi();
- A: `"It worked! Hello world!"`
- B: `"Oh no an error: undefined`
- C: `SyntaxError: can only throw Error objects`
-- D: `"Oh no an error: Hello world!`
+- D: `"Oh no an error! Hello world!`
Answer
#### Answer: D
-With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world'`.
+With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world!'`.
-With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world'`. `e` is now equal to that string, which we log. This results in `'Oh an error: Hello world'`.
+With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world~'`. `e` is now equal to that string, which we log. This results in `'Oh an error! Hello world!'`.
@@ -1638,7 +1638,7 @@ console.log(typeof y);
#### Answer: A
-`let x = y = 10;` is actually shorthand for:
+`let x = (y = 10);` is actually shorthand for:
```javascript
y = 10;
From 879aadb69627f08fcb5e1e72f268e244ccdab003 Mon Sep 17 00:00:00 2001
From: kimdanah
Date: Sun, 23 Jun 2019 03:53:53 +0900
Subject: [PATCH 063/881] Translate the questions 1-10 to Korean
---
README-ko_KR.md | 1658 +++++++++++++++++++++++++++++++++++++++++++++++
README.md | 2 +-
2 files changed, 1659 insertions(+), 1 deletion(-)
create mode 100644 README-ko_KR.md
diff --git a/README-ko_KR.md b/README-ko_KR.md
new file mode 100644
index 00000000..c50e3288
--- /dev/null
+++ b/README-ko_KR.md
@@ -0,0 +1,1658 @@
+# (고급) JavaScript 질문 목록
+
+JavaScript 에 관한 객관식 문제를 [Instagram](https://www.instagram.com/theavocoder)에 매일 게시하고 있어요, 물론 여기에도 게시할 거예요!
+
+초급부터 고급까지: JavaScript를 얼마나 잘 알고 있는지 테스트하거나, 지식을 조금 깊게 하거나, 코딩 면접을 준비하세요! :muscle: :rocket: 이 기록을 매주 새로운 질문으로 업데이트해요. 마지막 업데이트: 6월 21일
+
+정답은 질문 아래 접힌 부분에 있어요, 그냥 클릭하면 펼칠 수 있어요. 행운을 빌어요 :heart:
+
+[中文版本](./README-zh_CN.md)
+[Русский](./README_ru-RU.md)
+[Western Balkan](./README-bs_BS.md)
+[Deutsch](./README-de_DE.md)
+[Tiếng Việt](./README-vi.md)
+[日本語](./README-ja_JA.md)
+[Українська мова](./README-ua_UA.md)
+[한국어](./README-ko_KR.md)
+
+---
+
+###### 1. 무엇이 출력 될까요?
+
+```javascript
+function sayHi() {
+ console.log(name);
+ console.log(age);
+ var name = "Lydia";
+ let age = 21;
+}
+
+sayHi();
+```
+
+- A: `Lydia` 와 `undefined`
+- B: `Lydia` 와 `ReferenceError`
+- C: `ReferenceError` 와 `21`
+- D: `undefined` 와 `ReferenceError`
+
+정답
+
+
+#### 정답: D
+
+함수내에서, 우선 `var`키워드를 사용해 `name`변수를 선언해요. 이것은 변수가 정의되어 있는 행에 실제로 도달할 때까지, 변수는 `undefined`을 기본값으로 호이스팅 된(생성단계에 메모리 공간이 설정됨)는 것을 의미해요. `name`변수를 출력 하려는 줄에서 아직 변수를 정의하고 있지 않았기 때문에, `undefined`값을 유지하고 있어요.
+
+`let`키워드(그리고 `const`)를 가지는 변수들은, `var`와는 달리, 호이스팅되지만 초기화되지 않아요. 그것들을 선언(초기화)하는 줄 전에는 접근 할 수 없어요. 이것은 "일시적 사각지대"라고 불려요. 선언되기 전에 변수에 접근하려고 하면, JavaScript는 `ReferenceError`를 던져요.
+
+
+
+
+---
+
+###### 2. 무엇이 출력 될까요?
+
+```javascript
+for (var i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+
+for (let i = 0; i < 3; i++) {
+ setTimeout(() => console.log(i), 1);
+}
+```
+
+- A: `0 1 2` 와 `0 1 2`
+- B: `0 1 2` 와 `3 3 3`
+- C: `3 3 3` 와 `0 1 2`
+
+정답
+
+
+#### 정답: C
+
+JavaScript의 이벤트 큐 때문에, `setTimeout`의 콜백함수는 루프가 실행된 _후에_ 호출되요. 첫번째의 루프 변수 `i`는 `var`키워드를 사용해 선언되어 있으므로, 이 값은 전역변수가 되요. 루프 동안, 단항 연산자 `++`를 사용하여, 매번 `i`의 값을 `1`씩 증가했어요. `setTimeout`콜백 함수가 호출되기까지, 첫번째 예에서 `i`는 `3`과 같아요.
+
+두번째 루프에서, 변수 `i`는 `let`키워드를 사용해 선언되었어요: `let` (그리고 `const`)키워드로 선언된 변수는 블록 범위에요(블록은 `{ }` 사이의 모든것). 각각의 반복동안, `i`는 새로운 값을 가지고, 각각의 값은 루프 안쪽 범위에 있어요.
+
+
+
+
+---
+
+###### 3. 무엇이 출력 될까요?
+
+```javascript
+const shape = {
+ radius: 10,
+ diameter() {
+ return this.radius * 2;
+ },
+ perimeter: () => 2 * Math.PI * this.radius
+};
+
+shape.diameter();
+shape.perimeter();
+```
+
+- A: `20` 과 `62.83185307179586`
+- B: `20` 과 `NaN`
+- C: `20` 과 `63`
+- D: `NaN` 과 `63`
+
+정답
+
+
+#### 정답: B
+
+`diameter`의 값은 정규 함수인 반면, `perimeter`의 값은 화살표 함수라는 점에 유의해요.
+
+화살표 함수에서는, 통상적인 함수와는 달리, `this`키워드는 현재 주위의 범위를 참조해요! 이것은 `perimeter`를 부르면, shape 객체가 아닌, 그 주위의 범위(예를 들면 window)를 참조하는 것을 의미해요.
+
+그 객체에는 `radius`라는 값은 없고, `undefined`를 리턴해요.
+
+
+
+
+---
+
+###### 4. 무엇이 출력 될까요?
+
+```javascript
++true;
+!"Lydia";
+```
+
+- A: `1` 과 `false`
+- B: `false` 와 `NaN`
+- C: `false` 와 `false`
+
+정답
+
+
+#### 정답: A
+
+단항 더하기는 피연산자를 숫자로 변환하려 해요. `true`는 `1`, `false`은 `0`.
+
+문자열 `'Lydia'`는 참 같은 값이에요. 실제로 묻고 있는 것은, "이 참 같은 값이 거짓 같은 값인가?"에요. 이것은 `false`을 리턴해요.
+
+
+
+
+---
+
+###### 5. 정답은 어느 것일까요?
+
+```javascript
+const bird = {
+ size: "small"
+};
+
+const mouse = {
+ name: "Mickey",
+ small: true
+};
+```
+
+- A: `mouse.bird.size` 은 유효하지 않아요
+- B: `mouse[bird.size]` 은 유효하지 않아요
+- C: `mouse[bird["size"]]` 은 유효하지 않아요
+- D: 이 모든 것들은 유효해요.
+
+정답
+
+
+#### 정답: A
+
+JavaScript에서, 모든 객체 키는 문자열이에요 (Symbol이 아닌 한). 비록 그것을 문자열 _타입_ 으로 입력하지 않아도, 항상 밑바닥에서 문자열로 변환되요.
+
+JavaScript는 문장을 해석(또는 박스해제)해요. 대괄호 표기를 사용하면, 첫 번째 좌대괄호 `[`를 보고 오른쪽 대괄호 `]`를 찾을 때까지 진행해요. 그때, 그 문장을 평가할거에요.
+
+`mouse[bird.size]`: 먼저 `bird.size`를 평가해요, 이것은 `"small"`이에요. `mouse["small"]` 은 `true`를 리턴해요.
+
+그러나, 닷 표기에서는, 이것은 발생하지 않아요, `mouse`는 `bird`라고 불리는 키를 가지고 있지 않아요 즉, `mouse.bird`는 `undefined`를 의미해요.
+
+또, 닷 표기를 사용해 `size`를 물어봐요. `mouse.bird.size`. `mouse.bird`는 `undefined`로, 실제로는 `undefined.size`를 물어보고 있어요. 이것은 유효하지 않기 때문에, `Cannot read property "size" of undefined`와 비슷한 에러를 던질거에요.
+
+
+
+
+---
+
+###### 6. 무엇이 출력 될까요?
+
+```javascript
+let c = { greeting: "Hey!" };
+let d;
+
+d = c;
+c.greeting = "Hello";
+console.log(d.greeting);
+```
+
+- A: `Hello`
+- B: `Hey`
+- C: `undefined`
+- D: `ReferenceError`
+- E: `TypeError`
+
+정답
+
+
+#### 정답: A
+
+JavaScript에서, 모든 객체는 서로 동일하게 설정하면 _참조_ 에 따라 상호작용 해요.
+
+우선 변수 `c`는 객체에 대한 값을 유지해요. 그 후, `c`와 동일한 객체 참조를 `d`에 할당해요.
+
+
+
+한개의 객체를 변경하면, 그것들 모두 변경해요.
+
+
+
+
+---
+
+###### 7. 무엇이 출력 될까요?
+
+```javascript
+let a = 3;
+let b = new Number(3);
+let c = 3;
+
+console.log(a == b);
+console.log(a === b);
+console.log(b === c);
+```
+
+- A: `true` `false` `true`
+- B: `false` `false` `true`
+- C: `true` `false` `false`
+- D: `false` `true` `true`
+
+정답
+
+
+#### 정답: C
+
+`new Number()`는, 내장 함수 생성자에요. 숫자처럼 보이지만, 실제로는 숫자가 아니에요: 많은 추가 특징이 있고 그것은 객체에요.
+
+`==`연산자를 사용할 때, 그건 같은 _값_ 을 가지고 있는지 여부만 확인해요. 그것들은 모두`3`의 값을 가지고 있으므로, `true`를 리턴해요.
+
+그러나, `===`연산자를 사용할 때, 값 _과_ 타입 둘다 같아야 해요. 이건 아니에요: `new Number()`는 숫자가 아니에요. **객체**에요. 그래서 둘다 `false`를 리턴해요.
+
+
+
+
+---
+
+###### 8. 무엇이 출력 될까요?
+
+```javascript
+class Chameleon {
+ static colorChange(newColor) {
+ this.newColor = newColor;
+ return this.newColor;
+ }
+
+ constructor({ newColor = "green" } = {}) {
+ this.newColor = newColor;
+ }
+}
+
+const freddie = new Chameleon({ newColor: "purple" });
+freddie.colorChange("orange");
+```
+
+- A: `orange`
+- B: `purple`
+- C: `green`
+- D: `TypeError`
+
+정답
+
+
+#### 정답: D
+
+`colorChange`함수는 정적이에요. 정적 메소드는 그것들이 만들어지는 생성자 상에서만 살아있도록 설계되어 있어, 어떤 자식들도 상속 받을 수 없어요. `freddie`는 자식이기 때문에, 이 함수는 상속되지 않고, `freddie`인스턴스에서는 이용할 수 없어요: `TypeError`가 던져져요.
+
+
+
+
+---
+
+###### 9. 무엇이 출력 될까요?
+
+```javascript
+let greeting;
+greetign = {}; // Typo!
+console.log(greetign);
+```
+
+- A: `{}`
+- B: `ReferenceError: greetign is not defined`
+- C: `undefined`
+
+정답
+
+
+#### 정답: A
+
+객체는 출력되요, 전역객체에 빈 객체를 방금 만들었기 때문이에요. `greeting`을 `greettign`으로 잘못 입력했을 경우, JS 터프리터는 실제로 이것을 `global.greettign = {}` (또는 브라우저의 `window.greetign = {}`) 라고 간주해요.
+
+이것을 피하기 위해서, `"use strict"`를 사용할 수 있어요. 이렇게 하면 변수를 어떤 것과 동일하게 설정하기 전에 변수를 선언했는지 확인할 수 있어요.
+
+
+
+
+---
+
+###### 10. 이것을 하면 어떻게 될까요?
+
+```javascript
+function bark() {
+ console.log("Woof!");
+}
+
+bark.animal = "dog";
+```
+
+- A: 아무 일도 일어나지 않아요, 이건 완전히 괜찮아요!
+- B: `SyntaxError` 이 방법으로 함수에 속성을 추가할 수 없어요.
+- C: `undefined`
+- D: `ReferenceError`
+
+정답
+
+
+#### 정답: A
+
+JavaScript에서는 가능해요, 함수는 객체이기 때문이에요!
+(프리미티브형 이외는 모두 객체에요)
+
+함수는 특별한 종류의 객체에요. 자신이 쓴 코드는 실제 함수가 아니에요. 함수는 속성을 가진 객체에요. 이 속성은 호출이 가능해요.
+
+
+
+
+---
+
+###### 11. 무엇이 출력 될까요?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const member = new Person("Lydia", "Hallie");
+Person.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+
+console.log(member.getFullName());
+```
+
+- A: `TypeError`
+- B: `SyntaxError`
+- C: `Lydia Hallie`
+- D: `undefined` `undefined`
+
+정답
+
+
+#### 정답: A
+
+You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all objects at once, you have to use the prototype instead. So in this case,
+
+```js
+Person.prototype.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+```
+
+would have made `member.getFullName()` work. Why is this beneficial? Say that we added this method to the constructor itself. Maybe not every `Person` instance needed this method. This would waste a lot of memory space, since they would still have that property, which takes of memory space for each instance. Instead, if we only add it to the prototype, we just have it at one spot in memory, yet they all have access to it!
+
+
+
+
+---
+
+###### 12. 무엇이 출력 될까요?
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const lydia = new Person("Lydia", "Hallie");
+const sarah = Person("Sarah", "Smith");
+
+console.log(lydia);
+console.log(sarah);
+```
+
+- A: `Person {firstName: "Lydia", lastName: "Hallie"}` and `undefined`
+- B: `Person {firstName: "Lydia", lastName: "Hallie"}` and `Person {firstName: "Sarah", lastName: "Smith"}`
+- C: `Person {firstName: "Lydia", lastName: "Hallie"}` and `{}`
+- D:`Person {firstName: "Lydia", lastName: "Hallie"}` and `ReferenceError`
+
+정답
+
+
+#### 정답: A
+
+For `sarah`, we didn't use the `new` keyword. When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
+
+We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smith"`. What we actually did, is defining `global.firstName = 'Sarah'` and `global.lastName = 'Smith'`. `sarah` itself is left `undefined`.
+
+
+
+
+---
+
+###### 13. What are the three phases of event propagation?
+
+- A: Target > Capturing > Bubbling
+- B: Bubbling > Target > Capturing
+- C: Target > Bubbling > Capturing
+- D: Capturing > Target > Bubbling
+
+정답
+
+
+#### 정답: D
+
+During the **capturing** phase, the event goes through the ancestor elements down to the target element. It then reaches the **target** element, and **bubbling** begins.
+
+
+
+
+
+
+---
+
+###### 14. All object have prototypes.
+
+- A: true
+- B: false
+
+정답
+
+
+#### 정답: B
+
+All objects have prototypes, except for the **base object**. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
+
+
+
+
+---
+
+###### 15. 무엇이 출력 될까요?
+
+```javascript
+function sum(a, b) {
+ return a + b;
+}
+
+sum(1, "2");
+```
+
+- A: `NaN`
+- B: `TypeError`
+- C: `"12"`
+- D: `3`
+
+정답
+
+
+#### 정답: C
+
+JavaScript is a **dynamically typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
+
+In this example, JavaScript converts the number `1` into a string, in order for the function to make sense and return a value. During the addition of a numeric type (`1`) and a string type (`'2'`), the number is treated as a string. We can concatenate strings like `"Hello" + "World"`, so what's happening here is `"1" + "2"` which returns `"12"`.
+
+
+
+
+---
+
+###### 16. 무엇이 출력 될까요?
+
+```javascript
+let number = 0;
+console.log(number++);
+console.log(++number);
+console.log(number);
+```
+
+- A: `1` `1` `2`
+- B: `1` `2` `2`
+- C: `0` `2` `2`
+- D: `0` `1` `2`
+
+정답
+
+
+#### 정답: C
+
+The **postfix** unary operator `++`:
+
+1. Returns the value (this returns `0`)
+2. Increments the value (number is now `1`)
+
+The **prefix** unary operator `++`:
+
+1. Increments the value (number is now `2`)
+2. Returns the value (this returns `2`)
+
+This returns `0 2 2`.
+
+
+
+
+---
+
+###### 17. 무엇이 출력 될까요?
+
+```javascript
+function getPersonInfo(one, two, three) {
+ console.log(one);
+ console.log(two);
+ console.log(three);
+}
+
+const person = "Lydia";
+const age = 21;
+
+getPersonInfo`${person} is ${age} years old`;
+```
+
+- A: `"Lydia"` `21` `["", " is ", " years old"]`
+- B: `["", " is ", " years old"]` `"Lydia"` `21`
+- C: `"Lydia"` `["", " is ", " years old"]` `21`
+
+정답
+
+
+#### 정답: B
+
+If you use tagged template literals, the value of the first argument is always an array of the string values. The remaining arguments get the values of the passed expressions!
+
+
+
+
+---
+
+###### 18. 무엇이 출력 될까요?
+
+```javascript
+function checkAge(data) {
+ if (data === { age: 18 }) {
+ console.log("You are an adult!");
+ } else if (data == { age: 18 }) {
+ console.log("You are still an adult.");
+ } else {
+ console.log(`Hmm.. You don't have an age I guess`);
+ }
+}
+
+checkAge({ age: 18 });
+```
+
+- A: `You are an adult!`
+- B: `You are still an adult.`
+- C: `Hmm.. You don't have an age I guess`
+
+정답
+
+
+#### 정답: C
+
+When testing equality, primitives are compared by their _value_, while objects are compared by their _reference_. JavaScript checks if the objects have a reference to the same location in memory.
+
+The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
+
+This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }` return `false`.
+
+
+
+
+---
+
+###### 19. 무엇이 출력 될까요?
+
+```javascript
+function getAge(...args) {
+ console.log(typeof args);
+}
+
+getAge(21);
+```
+
+- A: `"number"`
+- B: `"array"`
+- C: `"object"`
+- D: `"NaN"`
+
+정답
+
+
+#### 정답: C
+
+The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
+
+
+
+
+---
+
+###### 20. 무엇이 출력 될까요?
+
+```javascript
+function getAge() {
+ "use strict";
+ age = 21;
+ console.log(age);
+}
+
+getAge();
+```
+
+- A: `21`
+- B: `undefined`
+- C: `ReferenceError`
+- D: `TypeError`
+
+정답
+
+
+#### 정답: C
+
+With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. If we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
+
+
+
+
+---
+
+###### 21. What's value of `sum`?
+
+```javascript
+const sum = eval("10*10+5");
+```
+
+- A: `105`
+- B: `"105"`
+- C: `TypeError`
+- D: `"10*10+5"`
+
+정답
+
+
+#### 정답: A
+
+`eval` evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is `10 * 10 + 5`. This returns the number `105`.
+
+
+
+
+---
+
+###### 22. How long is cool_secret accessible?
+
+```javascript
+sessionStorage.setItem("cool_secret", 123);
+```
+
+- A: Forever, the data doesn't get lost.
+- B: When the user closes the tab.
+- C: When the user closes the entire browser, not only the tab.
+- D: When the user shuts off their computer.
+
+정답
+
+
+#### 정답: B
+
+The data stored in `sessionStorage` is removed after closing the _tab_.
+
+If you used `localStorage`, the data would've been there forever, unless for example `localStorage.clear()` is invoked.
+
+
+
+
+---
+
+###### 23. 무엇이 출력 될까요?
+
+```javascript
+var num = 8;
+var num = 10;
+
+console.log(num);
+```
+
+- A: `8`
+- B: `10`
+- C: `SyntaxError`
+- D: `ReferenceError`
+
+정답
+
+
+#### 정답: B
+
+With the `var` keyword, you can declare multiple variables with the same name. The variable will then hold the latest value.
+
+You cannot do this with `let` or `const` since they're block-scoped.
+
+
+
+
+---
+
+###### 24. 무엇이 출력 될까요?
+
+```javascript
+const obj = { 1: "a", 2: "b", 3: "c" };
+const set = new Set([1, 2, 3, 4, 5]);
+
+obj.hasOwnProperty("1");
+obj.hasOwnProperty(1);
+set.has("1");
+set.has(1);
+```
+
+- A: `false` `true` `false` `true`
+- B: `false` `true` `true` `true`
+- C: `true` `true` `false` `true`
+- D: `true` `true` `true` `true`
+
+정답
+
+
+#### 정답: C
+
+All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
+
+It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')` returns `false`. It has the numeric type `1`, `set.has(1)` returns `true`.
+
+
+
+
+---
+
+###### 25. 무엇이 출력 될까요?
+
+```javascript
+const obj = { a: "one", b: "two", a: "three" };
+console.log(obj);
+```
+
+- A: `{ a: "one", b: "two" }`
+- B: `{ b: "two", a: "three" }`
+- C: `{ a: "three", b: "two" }`
+- D: `SyntaxError`
+
+정답
+
+
+#### 정답: C
+
+If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
+
+
+
+
+---
+
+###### 26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
+
+- A: true
+- B: false
+- C: it depends
+
+정답
+
+
+#### 정답: A
+
+The base execution context is the global execution context: it's what's accessible everywhere in your code.
+
+
+
+
+---
+
+###### 27. 무엇이 출력 될까요?
+
+```javascript
+for (let i = 1; i < 5; i++) {
+ if (i === 3) continue;
+ console.log(i);
+}
+```
+
+- A: `1` `2`
+- B: `1` `2` `3`
+- C: `1` `2` `4`
+- D: `1` `3` `4`
+
+정답
+
+
+#### 정답: C
+
+The `continue` statement skips an iteration if a certain condition returns `true`.
+
+
+
+
+---
+
+###### 28. 무엇이 출력 될까요?
+
+```javascript
+String.prototype.giveLydiaPizza = () => {
+ return "Just give Lydia pizza already!";
+};
+
+const name = "Lydia";
+
+name.giveLydiaPizza();
+```
+
+- A: `"Just give Lydia pizza already!"`
+- B: `TypeError: not a function`
+- C: `SyntaxError`
+- D: `undefined`
+
+정답
+
+
+#### 정답: A
+
+`String` is a built-in constructor, which we can add properties to. I just added a method to its prototype. Primitive strings are automatically converted into a string object, generated by the string prototype function. So, all strings (string objects) have access to that method!
+
+
+
+
+---
+
+###### 29. 무엇이 출력 될까요?
+
+```javascript
+const a = {};
+const b = { key: "b" };
+const c = { key: "c" };
+
+a[b] = 123;
+a[c] = 456;
+
+console.log(a[b]);
+```
+
+- A: `123`
+- B: `456`
+- C: `undefined`
+- D: `ReferenceError`
+
+정답
+
+
+#### 정답: B
+
+Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`.
+
+However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
+
+Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to `456`, so it returns `456`.
+
+
+
+
+---
+
+###### 30. 무엇이 출력 될까요?
+
+```javascript
+const foo = () => console.log("First");
+const bar = () => setTimeout(() => console.log("Second"));
+const baz = () => console.log("Third");
+
+bar();
+foo();
+baz();
+```
+
+- A: `First` `Second` `Third`
+- B: `First` `Third` `Second`
+- C: `Second` `First` `Third`
+- D: `Second` `Third` `First`
+
+정답
+
+
+#### 정답: B
+
+We have a `setTimeout` function and invoked it first. Yet, it was logged last.
+
+This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
+
+After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
+
+
+
+Now, `foo` gets invoked, and `"First"` is being logged.
+
+
+
+`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged.
+
+
+
+The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_.
+
+
+
+This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
+
+
+
+`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack.
+
+
+
+
+---
+
+###### 31. What is the event.target when clicking the button?
+
+```html
+
+```
+
+- A: Outer `div`
+- B: Inner `div`
+- C: `button`
+- D: An array of all nested elements.
+
+정답
+
+
+#### 정답: C
+
+The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+
+
+
+
+---
+
+###### 32. When you click the paragraph, what's the logged output?
+
+```html
+
+```
+
+- A: `p` `div`
+- B: `div` `p`
+- C: `p`
+- D: `div`
+
+정답
+
+
+#### 정답: A
+
+If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
+
+
+
+
+---
+
+###### 33. 무엇이 출력 될까요?
+
+```javascript
+const person = { name: "Lydia" };
+
+function sayHi(age) {
+ console.log(`${this.name} is ${age}`);
+}
+
+sayHi.call(person, 21);
+sayHi.bind(person, 21);
+```
+
+- A: `undefined is 21` `Lydia is 21`
+- B: `function` `function`
+- C: `Lydia is 21` `Lydia is 21`
+- D: `Lydia is 21` `function`
+
+정답
+
+
+#### 정답: D
+
+With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
+
+`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
+
+
+
+
+---
+
+###### 34. 무엇이 출력 될까요?
+
+```javascript
+function sayHi() {
+ return (() => 0)();
+}
+
+typeof sayHi();
+```
+
+- A: `"object"`
+- B: `"number"`
+- C: `"function"`
+- D: `"undefined"`
+
+정답
+
+
+#### 정답: B
+
+The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+
+FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+
+
+
+
+---
+
+###### 35. Which of these values are falsy?
+
+```javascript
+0;
+new Number(0);
+("");
+(" ");
+new Boolean(false);
+undefined;
+```
+
+- A: `0`, `''`, `undefined`
+- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
+- C: `0`, `''`, `new Boolean(false)`, `undefined`
+- D: All of them are falsy
+
+정답
+
+
+#### 정답: A
+
+There are only six falsy values:
+
+- `undefined`
+- `null`
+- `NaN`
+- `0`
+- `''` (empty string)
+- `false`
+
+Function constructors, like `new Number` and `new Boolean` are truthy.
+
+
+
+
+---
+
+###### 36. 무엇이 출력 될까요?
+
+```javascript
+console.log(typeof typeof 1);
+```
+
+- A: `"number"`
+- B: `"string"`
+- C: `"object"`
+- D: `"undefined"`
+
+정답
+
+
+#### 정답: B
+
+`typeof 1` returns `"number"`.
+`typeof "number"` returns `"string"`
+
+
+
+
+---
+
+###### 37. 무엇이 출력 될까요?
+
+```javascript
+const numbers = [1, 2, 3];
+numbers[10] = 11;
+console.log(numbers);
+```
+
+- A: `[1, 2, 3, 7 x null, 11]`
+- B: `[1, 2, 3, 11]`
+- C: `[1, 2, 3, 7 x empty, 11]`
+- D: `SyntaxError`
+
+정답
+
+
+#### 정답: C
+
+When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like:
+
+`[1, 2, 3, 7 x empty, 11]`
+
+depending on where you run it (it's different for every browser, node, etc.)
+
+
+
+
+---
+
+###### 38. 무엇이 출력 될까요?
+
+```javascript
+(() => {
+ let x, y;
+ try {
+ throw new Error();
+ } catch (x) {
+ (x = 1), (y = 2);
+ console.log(x);
+ }
+ console.log(x);
+ console.log(y);
+})();
+```
+
+- A: `1` `undefined` `2`
+- B: `undefined` `undefined` `undefined`
+- C: `1` `1` `2`
+- D: `1` `undefined` `undefined`
+
+정답
+
+
+#### 정답: A
+
+The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
+
+Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+
+Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+
+
+
+
+---
+
+###### 39. Everything in JavaScript is either a...
+
+- A: primitive or object
+- B: function or object
+- C: trick question! only objects
+- D: number or object
+
+정답
+
+
+#### 정답: A
+
+JavaScript only has primitive types and objects.
+
+Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+
+What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+
+
+
+
+---
+
+###### 40. 무엇이 출력 될까요?
+
+```javascript
+[[0, 1], [2, 3]].reduce(
+ (acc, cur) => {
+ return acc.concat(cur);
+ },
+ [1, 2]
+);
+```
+
+- A: `[0, 1, 2, 3, 1, 2]`
+- B: `[6, 1, 2]`
+- C: `[1, 2, 0, 1, 2, 3]`
+- D: `[1, 2, 6]`
+
+정답
+
+
+#### 정답: C
+
+`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
+
+Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
+
+
+
+
+---
+
+###### 41. 무엇이 출력 될까요?
+
+```javascript
+!!null;
+!!"";
+!!1;
+```
+
+- A: `false` `true` `false`
+- B: `false` `false` `true`
+- C: `false` `true` `true`
+- D: `true` `true` `false`
+
+정답
+
+
+#### 정답: B
+
+`null` is falsy. `!null` returns `true`. `!true` returns `false`.
+
+`""` is falsy. `!""` returns `true`. `!true` returns `false`.
+
+`1` is truthy. `!1` returns `false`. `!false` returns `true`.
+
+
+
+
+---
+
+###### 42. What does the `setInterval` method return in the browser?
+
+```javascript
+setInterval(() => console.log("Hi"), 1000);
+```
+
+- A: a unique id
+- B: the amount of milliseconds specified
+- C: the passed function
+- D: `undefined`
+
+정답
+
+
+#### 정답: A
+
+It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function.
+
+
+
+
+---
+
+###### 43. What does this return?
+
+```javascript
+[..."Lydia"];
+```
+
+- A: `["L", "y", "d", "i", "a"]`
+- B: `["Lydia"]`
+- C: `[[], "Lydia"]`
+- D: `[["L", "y", "d", "i", "a"]]`
+
+정답
+
+
+#### 정답: A
+
+A string is an iterable. The spread operator maps every character of an iterable to one element.
+
+
+
+
+---
+
+###### 44. 무엇이 출력 될까요?
+
+```javascript
+function* generator(i) {
+ yield i;
+ yield i * 2;
+}
+
+const gen = generator(10);
+
+console.log(gen.next().value);
+console.log(gen.next().value);
+```
+
+- A: `[0, 10], [10, 20]`
+- B: `20, 20`
+- C: `10, 20`
+- D: `0, 10 and 10, 20`
+
+정답
+
+
+#### 정답: C
+
+Regular functions cannot be stopped mid-way after invocation. However, a generator function can be "stopped" midway, and later continue from where it stopped. Every time a generator function encounters a `yield` keyword, the function yields the value specified after it. Note that the generator function in that case doesn’t _return_ the value, it _yields_ the value.
+
+First, we initialize the generator function with `i` equal to `10`. We invoke the generator function using the `next()` method. The first time we invoke the generator function, `i` is equal to `10`. It encounters the first `yield` keyword: it yields the value of `i`. The generator is now "paused", and `10` gets logged.
+
+Then, we invoke the function again with the `next()` method. It starts to continue where it stopped previously, still with `i` equal to `10`. Now, it encounters the next `yield` keyword, and yields `i * 2`. `i` is equal to `10`, so it returns `10 * 2`, which is `20`. This results in `10, 20`.
+
+
+
+
+---
+
+###### 45. What does this return?
+
+```javascript
+const firstPromise = new Promise((res, rej) => {
+ setTimeout(res, 500, "one");
+});
+
+const secondPromise = new Promise((res, rej) => {
+ setTimeout(res, 100, "two");
+});
+
+Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
+```
+
+- A: `"one"`
+- B: `"two"`
+- C: `"two" "one"`
+- D: `"one" "two"`
+
+정답
+
+
+#### 정답: B
+
+When we pass multiple promises to the `Promice.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged.
+
+
+
+
+---
+
+###### 46. 무엇이 출력 될까요?
+
+```javascript
+let person = { name: "Lydia" };
+const members = [person];
+person = null;
+
+console.log(members);
+```
+
+- A: `null`
+- B: `[null]`
+- C: `[{}]`
+- D: `[{ name: "Lydia" }]`
+
+정답
+
+
+#### 정답: D
+
+First, we declare a variable `person` with the value of an object that has a `name` property.
+
+
+
+Then, we declare a variable called `members`. We set the first element of that array equal to the value of the `person` variable. Objects interact by _reference_ when setting them equal to each other. When you assign a reference from one variable to another, you make a _copy_ of that reference. (note that they don't have the _same_ reference!)
+
+
+
+Then, we set the variable `person` equal to `null`.
+
+
+
+We are only modifying the value of the `person` variable, and not the first element in the array, since that element has a different (copied) reference to the object. The first element in `members` still holds its reference to the original object. When we log the `members` array, the first element still holds the value of the object, which gets logged.
+
+
+
+
+---
+
+###### 47. 무엇이 출력 될까요?
+
+```javascript
+const person = {
+ name: "Lydia",
+ age: 21
+};
+
+for (const item in person) {
+ console.log(item);
+}
+```
+
+- A: `{ name: "Lydia" }, { age: 21 }`
+- B: `"name", "age"`
+- C: `"Lydia", 21`
+- D: `["name", "Lydia"], ["age", 21]`
+
+정답
+
+
+#### 정답: B
+
+With a `for-in` loop, we can iterate through object keys, in this case `name` and `age`. Under the hood, object keys are strings (if they're not a Symbol). On every loop, we set the value of `item`equal to the current key it’s iterating over. First, `item` is equal to `name`, and gets logged. Then, `item` is equal to `age`, which gets logged.
+
+
+
+
+---
+
+###### 48. 무엇이 출력 될까요?
+
+```javascript
+console.log(3 + 4 + "5");
+```
+
+- A: `"345"`
+- B: `"75"`
+- C: `12`
+- D: `"12"`
+
+정답
+
+
+#### 정답: B
+
+Operator associativity is the order in which the compiler evaluates the expressions, either left-to-right or right-to-left. This only happens if all operators have the _same_ precedence. We only have one type of operator: `+`. For addition, the associativity is left-to-right.
+
+`3 + 4` gets evaluated first. This results in the number `7`.
+
+`7 + '5'` results in `"75"` because of coercion. JavaScript converts the number `7` into a string, see question 15. We can concatenate two strings using the `+`operator. `"7" + "5"` results in `"75"`.
+
+
+
+
+---
+
+###### 49. What's the value of `num`?
+
+```javascript
+const num = parseInt("7*6", 10);
+```
+
+- A: `42`
+- B: `"42"`
+- C: `7`
+- D: `NaN`
+
+정답
+
+
+#### 정답: C
+
+Only the first numbers in the string is returned. Based on the _radix_ (the second argument in order to specify what type of number we want to parse it to: base 10, hexadecimal, octal, binary, etc.), the `parseInt` checks whether the characters in the string are valid. Once it encounters a character that isn't a valid number in the radix, it stops parsing and ignores the following characters.
+
+`*` is not a valid number. It only parses `"7"` into the decimal `7`. `num` now holds the value of `7`.
+
+
+
+
+---
+
+###### 50. What's the output`?
+
+```javascript
+[1, 2, 3].map(num => {
+ if (typeof num === "number") return;
+ return num * 2;
+});
+```
+
+- A: `[]`
+- B: `[null, null, null]`
+- C: `[undefined, undefined, undefined]`
+- D: `[ 3 x empty ]`
+
+정답
+
+
+#### 정답: C
+
+When mapping over the array, the value of `num` is equal to the element it’s currently looping over. In this case, the elements are numbers, so the condition of the if statement `typeof num === "number"` returns `true`. The map function creates a new array and inserts the values returned from the function.
+
+However, we don’t return a value. When we don’t return a value from the function, the function returns `undefined`. For every element in the array, the function block gets called, so for each element we return `undefined`.
+
+
+
+
+---
+
+###### 51. 무엇이 출력 될까요?
+
+```javascript
+function getInfo(member, year) {
+ member.name = "Lydia";
+ year = 1998;
+}
+
+const person = { name: "Sarah" };
+const birthYear = "1997";
+
+getInfo(person, birthYear);
+
+console.log(person, birthYear);
+```
+
+- A: `{ name: "Lydia" }, "1997"`
+- B: `{ name: "Sarah" }, "1998"`
+- C: `{ name: "Lydia" }, "1998"`
+- D: `{ name: "Sarah" }, "1997"`
+
+정답
+
+
+#### 정답: A
+
+Arguments are passed by _value_, unless their value is an object, then they're passed by _reference_. `birthYear` is passed by value, since it's a string, not an object. When we pass arguments by value, a _copy_ of that value is created (see question 46).
+
+The variable `birthYear` has a reference to the value `"1997"`. The argument `year` also has a reference to the value `"1997"`, but it's not the same value as `birthYear` has a reference to. When we update the value of `year` by setting `year` equal to `"1998"`, we are only updating the value of `year`. `birthYear` is still equal to `"1997"`.
+
+The value of `person` is an object. The argument `member` has a (copied) reference to the _same_ object. When we modify a property of the object `member` has a reference to, the value of `person` will also be modified, since they both have a reference to the same object. `person`'s `name` property is now equal to the value `"Lydia"`
+
+
+
+
+---
+
+###### 52. 무엇이 출력 될까요?
+
+```javascript
+function greeting() {
+ throw "Hello world!";
+}
+
+function sayHi() {
+ try {
+ const data = greeting();
+ console.log("It worked!", data);
+ } catch (e) {
+ console.log("Oh no an error!", e);
+ }
+}
+
+sayHi();
+```
+
+- A: `"It worked! Hello world!"`
+- B: `"Oh no an error: undefined`
+- C: `SyntaxError: can only throw Error objects`
+- D: `"Oh no an error: Hello world!`
+
+정답
+
+
+#### 정답: D
+
+With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world'`.
+
+With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world'`. `e` is now equal to that string, which we log. This results in `'Oh an error: Hello world'`.
+
+
+
+
+---
+
+###### 53. 무엇이 출력 될까요?
+
+```javascript
+function Car() {
+ this.make = "Lamborghini";
+ return { make: "Maserati" };
+}
+
+const myCar = new Car();
+console.log(myCar.make);
+```
+
+- A: `"Lamborghini"`
+- B: `"Maserati"`
+- C: `ReferenceError`
+- D: `TypeError`
+
+정답
+
+
+#### 정답: B
+
+When you return a property, the value of the property is equal to the _returned_ value, not the value set in the constructor function. We return the string `"Maserati"`, so `myCar.make` is equal to `"Maserati"`.
+
+
+
+
+---
+
+###### 54. 무엇이 출력 될까요?
+
+```javascript
+(() => {
+ let x = (y = 10);
+})();
+
+console.log(typeof x);
+console.log(typeof y);
+```
+
+- A: `"undefined", "number"`
+- B: `"number", "number"`
+- C: `"object", "number"`
+- D: `"number", "undefined"`
+
+정답
+
+
+#### 정답: A
+
+`let x = y = 10;` is actually shorthand for:
+
+```javascript
+y = 10;
+let x = y;
+```
+
+When we set `y` equal to `10`, we actually add a property `y` to the global object (`window` in browser, `global` in Node). In a browser, `window.y` is now equal to `10`.
+
+Then, we declare a variable `x` with the value of `y`, which is `10`. Variables declared with the `let` keyword are _block scoped_, they are only defined within the block they're declared in; the immediately-invoked function (IIFE) in this case. When we use the `typeof` operator, the operand `x` is not defined: we are trying to access `x` outside of the block it's declared in. This means that `x` is not defined. Values who haven't been assigned a value or declared are of type `"undefined"`. `console.log(typeof x)` returns `"undefined"`.
+
+However, we created a global variable `y` when setting `y` equal to `10`. This value is accessible anywhere in our code. `y` is defined, and holds a value of type `"number"`. `console.log(typeof y)` returns `"number"`.
+
+
+
diff --git a/README.md b/README.md
index 3eb7e7e7..217ce423 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,7 @@ The answers are in the collapsed sections below the questions, simply click on t
[Tiếng Việt](./README-vi.md)
[日本語](./README-ja_JA.md)
[Українська мова](./README-ua_UA.md)
+[한국어](./README-ko_KR.md)
---
@@ -175,7 +176,6 @@ However, with dot notation, this doesn't happen. `mouse` does not have a key cal
---
-
###### 6. What's the output?
```javascript
From cdaa7d675f67fa5b37cc452026a978b8a1deb736 Mon Sep 17 00:00:00 2001
From: KL13NT
Date: Sat, 22 Jun 2019 21:30:09 +0200
Subject: [PATCH 064/881] Finished 47 questions
---
README_ar-EG.md | 554 +++++++++++++++++++++++-------------------------
1 file changed, 264 insertions(+), 290 deletions(-)
diff --git a/README_ar-EG.md b/README_ar-EG.md
index 247e318b..5e3dd9f5 100644
--- a/README_ar-EG.md
+++ b/README_ar-EG.md
@@ -7,6 +7,8 @@
الاجابات في الجزء المخفي تحت, ببساطة دوس على السؤال عشان تفتح تفاصيله. اتمنالكم حظ سعيد :heart:
+ملحوظة المترجم: الترجمه دي معموله بمزيج من اللغه الانجليزية و اللغه العامية العربية المستخدمه في مصر. انا مشيت في اتجاه اني استخدم اللغه الانجليزية في جزئيات معينه لأن مينفعش تتكتب بالعربي بطريقة او بأخرى من غير ما تفقد المعنى او يبقى البحث عنها بعد كده صعب. لو عندك اقتراح للترجمه اعمل منشن وانت بتعمل `issue` على الموقع هنا.
+
---
###### 1. ايه اللي هيتطبع؟
@@ -29,7 +31,7 @@ sayHi();
- ج: `ReferenceError` و `21`
- د: `undefined` و `ReferenceError`
-Answer
+الاجابة
#### الاجابة الصحيحة: د
@@ -467,19 +469,20 @@ console.log(sarah);
- أ: صحيحة
- ب: خطأ
-Answer
+الاجابة
-#### Answer: B
+#### الاجابة الصحيحة: ب
+
+كل العناصر في جافاسكربت ليها `prototype` ما عدا الـ**base object** و اللي كل العناصر بتاخد منه الدوال بتاعته. ده السبب اللي بيخليك تقدر تستعمل الدوال دي في اي عنصر تعمله.
-All objects have prototypes, except for the **base object**. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
---
-###### 15. What's the output?
+###### 15. ايه اللي هيتطبع؟
```javascript
@@ -491,26 +494,26 @@ sum(1, "2");
```
-- A: `NaN`
-- B: `TypeError`
-- C: `"12"`
-- D: `3`
+- أ: `NaN`
+- ب: `TypeError`
+- ج: `12`
+- د: `3`
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة الصحيحة: ج
-JavaScript is a **dynamically typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
+جافاسكربت `dynamic` و بالتالي احنا مش بنحدد نوع المتغير لما بنعمله و المتغير نوعه بيتغير عادي جداً و ممكن ده يحصل من غير ما تعرف حتى و ده اسمه `implicit coercion`.
-In this example, JavaScript converts the number `1` into a string, in order for the function to make sense and return a value. During the addition of a numeric type (`1`) and a string type (`'2'`), the number is treated as a string. We can concatenate strings like `"Hello" + "World"`, so what's happening here is `"1" + "2"` which returns `"12"`.
+في المثال ده بقى جافاسكربت هتحول رقم `1` الى `string` عشان الدالة تقدر تتعامل معاه و ترجع قيمة. و في عملية الجمع مابين القيمة العددية `1` و السترنج `"2"` الرقم هيتحول الى سترنج و بعد كده هيقوم متضاف الى السترنج التانية عشان يعمل سترنج `"12"`.
---
-###### 16. What's the output?
+###### 16. ايه اللي هيتطبع؟
@@ -522,34 +525,26 @@ console.log(number);
```
-- A: `1` `1` `2`
-- B: `1` `2` `2`
-- C: `0` `2` `2`
-- D: `0` `1` `2`
+- أ: `1` `1` `2`
+- ب: `1` `2` `2`
+- ج: `0` `2` `2`
+- د: `0` `1` `2`
-Answer
+الاجابة
-#### Answer: C
-
-The **postfix** unary operator `++`:
-
-1. Returns the value (this returns `0`)
-2. Increments the value (number is now `1`)
-
-The **prefix** unary operator `++`:
+#### الاجابة الصحيحة: ج
-1. Increments the value (number is now `2`)
-2. Returns the value (this returns `2`)
+العامل البعدي `x++` بيرجع القيمة الاصلية الاول بعد كده يزود واحد على المتغير
-This returns `0 2 2`.
+اما العامل القبلي `++x` بيعدل القيمة الاول و يرجع القيمة المعدلة
---
-###### 17. What's the output?
+###### 17. ايه اللي هيتطبع؟ (جرب تشغل السؤال ده عشان تفهمه كويس)
@@ -567,24 +562,24 @@ getPersonInfo`${person} is ${age} years old`;
```
+- أ: `"Lydia"` `21` `["", " is ", " years old"]`
+- ب: `["", " is ", " years old"]` `"Lydia"` `21`
+- ج: `"Lydia"` `["", " is ", " years old"]` `21`
-- A: `"Lydia"` `21` `["", " is ", " years old"]`
-- B: `["", " is ", " years old"]` `"Lydia"` `21`
-- C: `"Lydia"` `["", " is ", " years old"]` `21`
-
-Answer
+الاجابة
-#### Answer: B
+#### الاجابة الصحيحة: ب
+
-If you use tagged template literals, the value of the first argument is always an array of the string values. The remaining arguments get the values of the passed expressions!
+لو بتستعمل `tagged template literals` اول قيمة داخله للدالة دايماً هتكون `array` مليانه بالسترنج اللي داخله فقط من غير اي متغيرات و الباقي هياخدوا القيم اللي داخله بالترتيب.
---
-###### 18. What's the output?
+###### 18. ايه اللي هيتطبع؟
@@ -603,28 +598,26 @@ checkAge({ age: 18 });
```
+- أ: `You are an adult!`
+- ب: `You are still an adult.`
+- ج: `Hmm.. You don't have an age I guess`
-- A: `You are an adult!`
-- B: `You are still an adult.`
-- C: `Hmm.. You don't have an age I guess`
-
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة الصحيحة: ج
-When testing equality, primitives are compared by their _value_, while objects are compared by their _reference_. JavaScript checks if the objects have a reference to the same location in memory.
+لما بنقارن في جافاسكربت, القيم الـ`primitive` زي الارقام و السترنج البسيطة بيتم مقارنة قيمتها فقط بينما الاوبجكتس بيتم مقارنة الاشارة ليهم `reference`. يعني لما بنقارن اوبجكتس ببعض جافاسكربت بتشوف هل الاتنين بيشاوروا لنفس المكان في الرام ولا لا.
-The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
+و بما ان الاوبجكتس اللي بنقارنهم احنا هنا داخلين على انهم قيمتين مختلفتين للداله وبالتالي مش بيشيروا لنفس المكان ف الرام يبقى مش متساويين و ده السبب اللي بيخلي الاجابة بالشكل ده. المقارنه عشان تتم بشكل صحيح بقى ممكن تحولهم ل سترنج او تشوف القيم اللي جوا كل اوبجكت.
-This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }` return `false`.
---
-###### 19. What's the output?
+###### 19. ايه اللي هيتطبع؟
@@ -638,24 +631,25 @@ getAge(21);
-- A: `"number"`
-- B: `"array"`
-- C: `"object"`
-- D: `"NaN"`
+- أ: `"number"`
+- ب: `"array"`
+- ج: `"object"`
+- د: `"NaN"`
+
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة الصحيحة: ج
-The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
+معامل التفكيك `spread operator ...args` بيرجع `array` فيها الـقيم اللي داخله للدالة. و بما ان كل حاجه في جافاسكربت عبارة عن اوبجكت بما فيها الـ`array` يبقى القيمه اللي هترجع `"object"`
---
-###### 20. What's the output?
+###### 20. ايه اللي هيتطبع؟
@@ -671,24 +665,25 @@ getAge();
-- A: `21`
-- B: `undefined`
-- C: `ReferenceError`
-- D: `TypeError`
+- أ: `21`
+- ب: `undefined`
+- ج: `ReferenceError`
+- د: `TypeError`
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة الصحيحة: ج
+
+لما بنستعمل `"use strict"` تقدر تتأكد ان انت مش بتعمل متغيرات `global` عن طريق الخطأ. احنا هنا عمرنا ما عملنا `declare` للمتغير `age` اصلاً و بما اننا بنستعمل `"use strict"` البرنامج هيدينا خطأ من نوع `ReferenceError`.
-With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. If we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
---
-###### 21. What's value of `sum`?
+###### 21. ايه قيمة `sum`?
@@ -697,25 +692,25 @@ const sum = eval("10*10+5");
```
+- أ: `105`
+- ب: `"105"`
+- ج: `TypeError`
+- د: `"10*10+5"`
-- A: `105`
-- B: `"105"`
-- C: `TypeError`
-- D: `"10*10+5"`
-
-Answer
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
+
+الدالة `eval` بتشغل الكود اللي داخلها على هيئة `string`. لو السترنج دي بتعبر عن عملية حسابية مثلاً هتقوم مشغله العملية دي و بالتالي `10 * 10 + 5` هيرجع القيمة العددية `105`.
-`eval` evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is `10 * 10 + 5`. This returns the number `105`.
---
-###### 22. How long is cool_secret accessible?
+###### 22. cool_secret هتفضل موجوده قد ايه؟
@@ -724,27 +719,26 @@ sessionStorage.setItem("cool_secret", 123);
```
+- أ: للأبد, عمرها ما هتتمسح
+- ب: لما المستخدم يقفل التبويب
+- ج: لما المستخدم يقفل نافذة المتصفح كلها
+- د: لما المستخدم يطفي الكمبيوتر بتاعه
-- A: Forever, the data doesn't get lost.
-- B: When the user closes the tab.
-- C: When the user closes the entire browser, not only the tab.
-- D: When the user shuts off their computer.
-
-Answer
+الاجابة
-#### Answer: B
+#### الاجابة الصحيحة: ب
-The data stored in `sessionStorage` is removed after closing the _tab_.
+اي معلومات بيتم تخزينها في الـ`sessionStorage` بتتمسح مجرد ما المستخدم يقفل التبويب.
-If you used `localStorage`, the data would've been there forever, unless for example `localStorage.clear()` is invoked.
+لو استخدمت `localStorage` المعلومات هتفضل موجوده للأبد او لحد ما تمسحها انت بنفسك في الكود.
---
-###### 23. What's the output?
+###### 23. ايه اللي هيتطبع؟
@@ -756,27 +750,25 @@ console.log(num);
```
+- أ: `8`
+- ب: `10`
+- ج: `SyntaxError`
+- د: `ReferenceError`
-- A: `8`
-- B: `10`
-- C: `SyntaxError`
-- D: `ReferenceError`
-Answer
+الاجابة
-#### Answer: B
-
-With the `var` keyword, you can declare multiple variables with the same name. The variable will then hold the latest value.
+#### الاجابة الصحيحة: ب
-You cannot do this with `let` or `const` since they're block-scoped.
+مع كلمة `var` احنا بنعمل المتغير من اول و جديد بنفس الاسم و بقيم مختلفه و بالتالي اخر قيمه بس هي اللي هتكون موجودة. مش بيحصل كده مع `let` و `const`.
---
-###### 24. What's the output?
+###### 24. ايه اللي هيتطبع؟
@@ -791,27 +783,26 @@ set.has(1);
```
+- أ: `false` `true` `false` `true`
+- ب: `false` `true` `true` `true`
+- ج: `true` `true` `false` `true`
+- د: `true` `true` `true` `true`
-- A: `false` `true` `false` `true`
-- B: `false` `true` `true` `true`
-- C: `true` `true` `false` `true`
-- D: `true` `true` `true` `true`
-
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة الصحيحة: ج
-All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
+كل مفاتيح العناصر `object keys` ما عدا اللي من نوع `Symbol` عبارة عن قيم `string` حتى لو انت مش كاتبها كسترنج. و ده السبب ان `obj.hasOwnProperty('1')` برضه بترجع `true`
-It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')` returns `false`. It has the numeric type `1`, `set.has(1)` returns `true`.
+اما بالنسبه لنوع `set` فا اللي معانا حالياً جواها قيم عددية فقط و بالتالي الـ`string` `'1'` مش موجوده.
---
-###### 25. What's the output?
+###### 25. ايه اللي هيتطبع؟
@@ -822,42 +813,44 @@ console.log(obj);
-- A: `{ a: "one", b: "two" }`
-- B: `{ b: "two", a: "three" }`
-- C: `{ a: "three", b: "two" }`
-- D: `SyntaxError`
+- أ: `{ a: "one", b: "two" }`
+- ب: `{ b: "two", a: "three" }`
+- ج: `{ a: "three", b: "two" }`
+- د: `SyntaxError`
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة الصحيحة: ج
+
+لو عندك في العنصر اكتر من قيمة `object key` بنفس الاسم, هيتم استبدال القيم اللي موجوده بآخر قيمة تم تسجيلها.
-If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
---
-###### 26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
+###### 26. في جافاسكربت, بنلاقي حاجتين موجودين دايماً وهما الـ `global` و كلمة ال `this` المفتاحية. العبارة دي:
-- A: true
-- B: false
-- C: it depends
+- أ: صحيحة
+- ب: خاطئة
+- ج: تعتمد
-Answer
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
+
+و دي حاجه اسمها `global execution context` واللي يمكن اعتباره عن محيط او البيئة اللي الكوود بيشتغل فيه و بيكون فيه المتغيرات الـ`global` كلها.
-The base execution context is the global execution context: it's what's accessible everywhere in your code.
---
-###### 27. What's the output?
+###### 27. ايه اللي هيتطبع؟
@@ -869,25 +862,25 @@ for (let i = 1; i < 5; i++) {
```
+- أ: `1` `2`
+- ب: `1` `2` `3`
+- ج: `1` `2` `4`
+- د: `1` `3` `4`
-- A: `1` `2`
-- B: `1` `2` `3`
-- C: `1` `2` `4`
-- D: `1` `3` `4`
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة الصحيحة: ج
-The `continue` statement skips an iteration if a certain condition returns `true`.
+كلمة `continue` بتخلي اللووب تكمل لو الشرط اللي هي جواه اتحقق.
---
-###### 28. What's the output?
+###### 28. ايه اللي هيتطبع؟
@@ -903,24 +896,25 @@ name.giveLydiaPizza();
-- A: `"Just give Lydia pizza already!"`
-- B: `TypeError: not a function`
-- C: `SyntaxError`
-- D: `undefined`
-Answer
+- أ: `"Just give Lydia pizza already!"`
+- ب: `TypeError: not a function`
+- ج: `SyntaxError`
+- د: `undefined`
+
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
-`String` is a built-in constructor, which we can add properties to. I just added a method to its prototype. Primitive strings are automatically converted into a string object, generated by the string prototype function. So, all strings (string objects) have access to that method!
+`String` هو فنكشن `constructor` واللي بنقدر نضيف خواص و قيم ليه. انا هنا ضيفت دالة للـ`prototype` بتاعه. المتغيرات البدائية `primitive` بيتم تحويلها بطريقة تلقائياً الى عنصر `object` وبالتالي بيكون ليها القدره انها تشغل الدوال الخاصه بالنوع ده.
---
-###### 29. What's the output?
+###### 29. ايه اللي هيتطبع؟
@@ -936,29 +930,25 @@ console.log(a[b]);
```
+- أ: `123`
+- ب: `456`
+- ج: `undefined`
+- د: `ReferenceError`
-- A: `123`
-- B: `456`
-- C: `undefined`
-- D: `ReferenceError`
-
-Answer
+الاجابة
-#### Answer: B
-
-Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`.
+#### الاجابة الصحيحة: ب
-However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
+مفاتيح العناصر `Object keys` بيتم تحويلهم تلقائياً الى string. احنا هنا بنحاول نحط اوبجكت على انه مفتاح لأوبجكت تاني. بس المشكلة ان لما نعمل كده مش بيترجم لأسمه او لمحتوياته بل بيتحول الى `[Object object] و بالتالي احنا كنا كأننا بالظبط عاملين `a["Object object"]=123` و بنكرر كده مع `c` و بعد كده بنقوم طابعين `a[b]` اللي احنا لسه مخليين مفتاحها من شوية `a["Object object"]` و خلينا القيمة بتاعته 456 و بالتالي دي اللي بتطبع.
-Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to `456`, so it returns `456`.
---
-###### 30. What's the output?
+###### 30. ايه اللي هيتطبع؟
@@ -973,49 +963,38 @@ baz();
```
+- أ: `First` `Second` `Third`
+- ب: `First` `Third` `Second`
+- ج: `Second` `First` `Third`
+- د: `Second` `Third` `First`
-- A: `First` `Second` `Third`
-- B: `First` `Third` `Second`
-- C: `Second` `First` `Third`
-- D: `Second` `Third` `First`
-
-Answer
+الاجابة
-#### Answer: B
+#### الاجابة الصحيحة: ب
-We have a `setTimeout` function and invoked it first. Yet, it was logged last.
+عندنا دالة `setTimeout` و المفروض تشتغل الاول و لكن اللي جواها اتشغل اخر حاجه. ايه اللي حصل؟
-This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
+في المتصفحات محرك الجافاسكربت مش لوحده اللي موجود, بل موجود كمان معاه حاجه اسمها `Web Application APIs` واختصارها `WebAPIs` ودي بتديلك شوية دوال و حاجات زيادة عن اللغه الاساسية زي `setTimeout` اللي مش في اللغه اصلاً.
-After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
+اللي بيحصل بقى ان الدالة اللي جوا `setTimeout` اللي هي الـ `callback` بتتجهز عشان تشتغل, و `setTimeout` نفسها بتخلص, و بعد كده البرنامج بينط على طول على الدالة اللي بعدها و بتشغلها و اللي بعدها و بتشغلها لحد ما ميتبقاش حاجه شاغله المتصفح بعد كده يقوم البرنامج مشغل الـ`callback` اللي كانت متجهزه.
-Now, `foo` gets invoked, and `"First"` is being logged.
-
-`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged.
-
-The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_.
-
-This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
-
-`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack.
-
---
-###### 31. What is the event.target when clicking the button?
+###### 31. ايه قيمة `event.target` لما تدوس على الزرار؟
```html
@@ -1029,25 +1008,26 @@ This is where an event loop starts to work. An **event loop** looks at the stack
```
+- أ: Outer `div`
+- ب: Inner `div`
+- ج: `button`
+- د: اراي جواها كل العناصر اللي جوا الزرار
-- A: Outer `div`
-- B: Inner `div`
-- C: `button`
-- D: An array of all nested elements.
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة الصحيحة: ج
-The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+هدف الحدث بيكون اخر عنصر في سلسلة الابناء و تقدر تمنع ده عن طريق `event.stopPropagation`.
---
-###### 32. When you click the paragraph, what's the logged output?
+###### 32. لما تدوس على البرجراف ايه اللي هيتطبع؟
+
```html
@@ -1059,24 +1039,24 @@ The deepest nested element that caused the event is the target of the event. You
```
-- A: `p` `div`
-- B: `div` `p`
-- C: `p`
-- D: `div`
+- أ: `p` `div`
+- ب: `div` `p`
+- ج: `p`
+- د: `div`
-Answer
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
-If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
+لما تدوس على البرجراف هتلاقي حاجتين ظهروا: `p` و `div`. و اثناء ما الحدث بيتم التعامل معاه بيحصل 3 مراحل زي ما قولنا في سؤال قبل كده. الاساسي ان الدوال اللي انت بتحددها عشان تتعامل مع الاحداث بتشتغل في اخر مرحله و هي الـ`Bubbling` و بالتالي هيتشغل من اعمق عنصر الى اكبر عنصر.
---
-###### 33. What's the output?
+###### 33. ايه اللي هيتطبع؟
@@ -1092,27 +1072,25 @@ sayHi.bind(person, 21);
```
+- أ: `undefined is 21` `Lydia is 21`
+- ب: `function` `function`
+- ج: `Lydia is 21` `Lydia is 21`
+- د: `Lydia is 21` `function`
-- A: `undefined is 21` `Lydia is 21`
-- B: `function` `function`
-- C: `Lydia is 21` `Lydia is 21`
-- D: `Lydia is 21` `function`
-
-Answer
+الاجابة
-#### Answer: D
+#### الاجابة الصحيحة: د
-With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
+في الحالتين بنقدر نحدد احنا عايزين كلمة `this` تشير لأيه بالظبط. بس الفرق ان `call` بتشتغل على طول اما `bind` بترجع نسخة جديدة من الدالة اللي دخلتلها قيمة `this` بتاعتها اللي احنا محددينها بس مش بتشتغل على طول.
-`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
---
-###### 34. What's the output?
+###### 34. ايه اللي هيتطبع؟
@@ -1125,27 +1103,26 @@ typeof sayHi();
```
+- أ: `"object"`
+- ب: `"number"`
+- ج: `"function"`
+- د: `"undefined"`
-- A: `"object"`
-- B: `"number"`
-- C: `"function"`
-- D: `"undefined"`
-
-Answer
+الاجابة
-#### Answer: B
+#### الاجابة الصحيحة: ب
-The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+الدالة `sayHi` بترجع القيمة اللي بتيجي من الدالة ذاتية التشغيل (IIFE) و اللي بدورها بترجع قيمة نوعها `"number"`.
-FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+ولمعلومات القارئ: في 3 انواع فقط في الجافاسكربت: `null`, `undefined`, `boolean`, `number`, `string`, `object` و `symbol`. الدوال ليست نوع و انما هما عناصر من نوع `object`.
---
-###### 35. Which of these values are falsy?
+###### 35. انهي قيمة من دول سالبية `false`؟
@@ -1159,18 +1136,17 @@ undefined;
```
+- أ: `0`, `''`, `undefined`
+- ب: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
+- ج: `0`, `''`, `new Boolean(false)`, `undefined`
+- د: كلهم
-- A: `0`, `''`, `undefined`
-- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
-- C: `0`, `''`, `new Boolean(false)`, `undefined`
-- D: All of them are falsy
-
-Answer
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
-There are only six falsy values:
+موجود في اللغه 6 قيم سالبية `false` فقط:
- `undefined`
- `null`
@@ -1179,14 +1155,14 @@ There are only six falsy values:
- `''` (empty string)
- `false`
-Function constructors, like `new Number` and `new Boolean` are truthy.
+اي `constructor` بيكون ايجابي `truthy` علشان بيرجع قيمة مش واحدة من اللي 6 دول.
---
-###### 36. What's the output?
+###### 36. ايه اللي هيتطبع؟
@@ -1195,26 +1171,24 @@ console.log(typeof typeof 1);
```
+- أ: `"number"`
+- ب: `"string"`
+- ج: `"object"`
+- د: `"undefined"`
-- A: `"number"`
-- B: `"string"`
-- C: `"object"`
-- D: `"undefined"`
-
-Answer
+الاجابة
-#### Answer: B
+#### الاجابة الصحيحة: ب
-`typeof 1` returns `"number"`.
-`typeof "number"` returns `"string"`
+`typeof 1` هترجع `"number"` و لاحظ ان دي مابين `""` يعني سترنج و بالتالي لما تدخل في الـ `typeof "number"` هترجع `"string"`
---
-###### 37. What's the output?
+###### 37. ايه اللي هيتطبع؟
@@ -1225,29 +1199,29 @@ console.log(numbers);
```
+- أ: `[1, 2, 3, 7 x null, 11]`
+- ب: `[1, 2, 3, 11]`
+- ج: `[1, 2, 3, 7 x empty, 11]`
+- د: `SyntaxError`
-- A: `[1, 2, 3, 7 x null, 11]`
-- B: `[1, 2, 3, 11]`
-- C: `[1, 2, 3, 7 x empty, 11]`
-- D: `SyntaxError`
-
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة الصحيحة: ج
-When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like:
+لما بتحط قيمة في مكان في `array` و المكان ده بيتعدى عدد المساحات الموجوده في الاراي (طولها) بتقوم جافاسكربت بعمل حاجه اسمها "مساحات فارغه" "empty slots" واللي بيكونوا قيمهم `undefined` ولكن لما تبص في الكونسول بتاعت المتصفح مثلاً هتلاقي الشكل طالعلك كده:
`[1, 2, 3, 7 x empty, 11]`
-depending on where you run it (it's different for every browser, node, etc.)
+و الشكل بيعتمد على حسب انت بتشغل الكود فين. كل متصفح بيطلعها بشكل مختلف, و تقدر تجربها بنفسك.
+
---
-###### 38. What's the output?
+###### 38. ايه اللي هيتطبع؟
@@ -1266,52 +1240,49 @@ depending on where you run it (it's different for every browser, node, etc.)
```
+- أ: `1` `undefined` `2`
+- ب: `undefined` `undefined` `undefined`
+- ج: `1` `1` `2`
+- د: `1` `undefined` `undefined`
-- A: `1` `undefined` `2`
-- B: `undefined` `undefined` `undefined`
-- C: `1` `1` `2`
-- D: `1` `undefined` `undefined`
-Answer
+الاجابة
-#### Answer: A
-
-The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
+#### الاجابة الصحيحة: أ
-Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+جزء الـ`catch` بيستلم متغير `x` بس الفرق ان الاكس في الحاله دي مش بتاعت الداله و انما ده متغير موجود فقط لجزء الـ `catch`. بعد كده احنا قومنا مغيرين القيمة بتاعته الى `1` و غيرنا قيمة المتغير `y` الى `2`. بعد كده قومنا طابعين القيم اللي موجودة جوا جزء الـ`catch` فقط.
-Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+برا الجزء بتاع الـ`catch` اكس هيفضل برضه `undefined` و `y` بما ان مفيش الا واحدة بس و هي بتاعت الدالة الاساسية واحنا غيرنا قيمتها بالتالي هتفضل على القيمة المتغيره اللي هي `2`.
---
-###### 39. Everything in JavaScript is either a...
+###### 39. كل حاجه في جافاسكربت ...
-- A: primitive or object
-- B: function or object
-- C: trick question! only objects
-- D: number or object
+- أ: primitive او عنصر `object`
+- ب: function او عنصر `object`
+- ج: عناصر `object` بس!
+- د: رقم او عنصر `object`
-Answer
-
-#### Answer: A
+الاجابة
+
-JavaScript only has primitive types and objects.
+#### الاجابة الصحيحة: أ
-Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+جافاسكربت فيها انواع بدائية\بسيطة `primitives` و عناصر `object` فقط. الانواع البسيطة هما: `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, و `symbol`
-What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+الفرق بين البسيطة و العناصر ان البسيطة مفيهاش اي دوال `methods` ولكن بنلاحظ ان لما مثلاُ بنحاول نشغل دالة على نوع بسيط زي `'foo'.toUpperCase()` الداله بتشتغل عادي جداً من غير ما تدينا خطأ `TypeError` و ده لأن زي ما قولنا في اجابة سابقه ان لما بنحاول نستغل الدوال دول جافاسكربت بتقوم تلقائياً بتحويل القيم البدائية اللي بنحاول نشغل عليها الدوال دي الى قيم من نوع `object` عشان تقدر تشغل الدوال دول و بعد كده ترجعها زي ما كانت. كل الانواع البسيطة بينطبق عليها الكلام ده ما عدا `undefined` و `null`.
---
-###### 40. What's the output?
+###### 40. ايه اللي هيتطبع؟
@@ -1325,27 +1296,26 @@ What differentiates a primitive from an object is that primitives do not have an
```
+- أ: `[0, 1, 2, 3, 1, 2]`
+- ب: `[6, 1, 2]`
+- ج: `[1, 2, 0, 1, 2, 3]`
+- د: `[1, 2, 6]`
-- A: `[0, 1, 2, 3, 1, 2]`
-- B: `[6, 1, 2]`
-- C: `[1, 2, 0, 1, 2, 3]`
-- D: `[1, 2, 6]`
-Answer
+الاجابة
-#### Answer: C
+#### الاجابة الصحيحة: ج
-`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
+الاراي `[1,2]` هي القيمه الاساسية اللي معانا و اللي هنبدأ بيها و هي برضه اول قيمة للمتغير `acc`. في الدورة الاولى المتغير `acc` قيمته `[1,2]` و المتغير `cur` قيمته `[0,1]` و لما نجمعهم سوا بيكون الناتج `[1,2,0,1]` و بعد كده المتغير `acc` بياخد القيمة دي و يقوم دامجها مع `[2,3]` اللي هي قيمة `cur` في الدورة التانية و اللي بدوره بيدي الناتج النهائي `[1, 2, 0, 1, 2, 3]`.
-Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
---
-###### 41. What's the output?
+###### 41. ايه اللي هيتطبع؟
@@ -1357,28 +1327,30 @@ Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and ge
-- A: `false` `true` `false`
-- B: `false` `false` `true`
-- C: `false` `true` `true`
-- D: `true` `true` `false`
+- أ: `false` `true` `false`
+- ب: `false` `false` `true`
+- ج: `false` `true` `true`
+- د: `true` `true` `false`
+
-Answer
+الاجابة
-#### Answer: B
+#### الاجابة الصحيحة: ب
+
+`null` قيمة سالبية `falsy` و بالتالي `!null` هترجع قيمة ايجابية `true` و بعد كده بتخش `!true` فا تتحول `false`
-`null` is falsy. `!null` returns `true`. `!true` returns `false`.
+وزي ما قولنا `""` دي قيمة سالبية لما نجيب عكسها هتتحول هي لـ`false` و بعد كده السالب بتاعها هيكون `true` و بعد كده تدخل في سالب تاني فتبقى `false`
-`""` is falsy. `!""` returns `true`. `!true` returns `false`.
+بعد كده عندنا رقم `1` اللي هو قيمة ايجابية و بدوره بيتحول مره يبقى سالبية و بعد كده يبقى ايجابية `true`.
-`1` is truthy. `!1` returns `false`. `!false` returns `true`.
---
-###### 42. What does the `setInterval` method return in the browser?
+###### 42. دالة `setInterval` بترجع ايه في المتصفح؟
@@ -1388,24 +1360,25 @@ setInterval(() => console.log("Hi"), 1000);
-- A: a unique id
-- B: the amount of milliseconds specified
-- C: the passed function
-- D: `undefined`
+- أ: اسم تعريفي فريد من نوعه `unique id`
+- ب: الوقت المحدد
+- ج: الداله المدخله معاها
+- د: `undefined`
-Answer
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
+
+دالة `setInterval` بترجع اسم تعريفي فريد تقدر تستعمله في `clearInterval` عشان توقف بيه التكرار.
-It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function.
---
-###### 43. What does this return?
+###### 43. ايه القيمة اللي هتطلع هنا؟
@@ -1415,17 +1388,18 @@ It returns a unique id. This id can be used to clear that interval with the `cle
-- A: `["L", "y", "d", "i", "a"]`
-- B: `["Lydia"]`
-- C: `[[], "Lydia"]`
-- D: `[["L", "y", "d", "i", "a"]]`
+- أ: `["L", "y", "d", "i", "a"]`
+- ب: `["Lydia"]`
+- ج: `[[], "Lydia"]`
+- د: `[["L", "y", "d", "i", "a"]]`
-Answer
+الاجابة
-#### Answer: A
+#### الاجابة الصحيحة: أ
+
+القيم اللي من نوع `string` بنقدر نعدي عليها عادي و بالتالي بنقدر نستعمل الـ Spread operator `...x` عشان نحول كل حرف الى عنصر في اراي.
-A string is an iterable. The spread operator maps every character of an iterable to one element.
From d6db33e526717aa3737eb9300f382cc6fd032d3f Mon Sep 17 00:00:00 2001
From: Nabil Tharwat
Date: Sat, 22 Jun 2019 21:32:25 +0200
Subject: [PATCH 065/881] Added Egyptian Arabic file link
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 916fa133..96fd23b2 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ The answers are in the collapsed sections below the questions, simply click on t
[Western Balkan](./README-bs_BS.md)
[Deutsch](./README-de_DE.md)
[Tiếng Việt](./README-vi.md)
-
+[اللغة العامية - Egyptian Arabic](./README_ar-EG.md)
---
From 30172b48b64c405d81d1f3cd8f84c1547fff3be4 Mon Sep 17 00:00:00 2001
From: Ihor Sychevskyi <26163841+Arhell@users.noreply.github.com>
Date: Sun, 23 Jun 2019 00:58:47 +0300
Subject: [PATCH 066/881] Upd links & fix typo
---
README-ua_UA.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/README-ua_UA.md b/README-ua_UA.md
index 18f2d4af..0a1a935e 100644
--- a/README-ua_UA.md
+++ b/README-ua_UA.md
@@ -8,9 +8,10 @@
[中文版本](./README-zh_CN.md)
[Русский](./README_ru-RU.md)
-[Western Balkan](./README-bs.md)
+[Western Balkan](./README-bs_BS.md)
[Deutsch](./README-de_DE.md)
[Tiếng Việt](./README-vi.md)
+[日本語](./README-ja_JA.md)
---
@@ -37,7 +38,7 @@ sayHi();
#### Відповідь: D
-Усередині функції ми спершу визначаємо змінну `name` за допомогою ключового слова `var`. Це означає, що змінна буде знайдена (область пам'яті під змінну буде виділена під час створення) зі значенням `undefined` за замовчуванням, до тих пора поки виконання коду не дійде до рядка, де визначається змінна. Ми ще не визначили значення name, коли намагаємося вивести її в консоль, тому в консолі буде `undefined`.
+Усередині функції ми спершу визначаємо змінну `name` за допомогою ключового слова `var`. Це означає, що змінна буде знайдена (область пам'яті під змінну буде виділена під час створення) зі значенням `undefined` за замовчуванням, до тих пір поки виконання коду не дійде до рядка, де визначається змінна. Ми ще не визначили значення name, коли намагаємося вивести її в консоль, тому в консолі буде `undefined`.
Змінні, визначені за допомогою `let` (і `const`), також знаходяться, але на відміну від `var`, не створюються. Доступ до них неможливий до тих пір, поки не виконається рядок їх визначення (ініціалізації). Це називається "тимчасова мертва зона". Коли ми намагаємося звернутися до змінних до того моменту як вони визначені, JavaScript видає `ReferenceError`.
From 06fb9abe1c7a7c0cec5e9da6f73d865ebc72a30f Mon Sep 17 00:00:00 2001
From: kimdanah
Date: Mon, 24 Jun 2019 00:18:33 +0900
Subject: [PATCH 067/881] Translate the questions 11-20 to Korean
---
README-ko_KR.md | 92 ++++++++++++++++++++++++-------------------------
1 file changed, 46 insertions(+), 46 deletions(-)
diff --git a/README-ko_KR.md b/README-ko_KR.md
index c50e3288..13154c27 100644
--- a/README-ko_KR.md
+++ b/README-ko_KR.md
@@ -30,10 +30,10 @@ function sayHi() {
sayHi();
```
-- A: `Lydia` 와 `undefined`
-- B: `Lydia` 와 `ReferenceError`
-- C: `ReferenceError` 와 `21`
-- D: `undefined` 와 `ReferenceError`
+- A: `Lydia` 그리고 `undefined`
+- B: `Lydia` 그리고 `ReferenceError`
+- C: `ReferenceError` 그리고 `21`
+- D: `undefined` 그리고 `ReferenceError`
정답
@@ -61,9 +61,9 @@ for (let i = 0; i < 3; i++) {
}
```
-- A: `0 1 2` 와 `0 1 2`
-- B: `0 1 2` 와 `3 3 3`
-- C: `3 3 3` 와 `0 1 2`
+- A: `0 1 2` 그리고 `0 1 2`
+- B: `0 1 2` 그리고 `3 3 3`
+- C: `3 3 3` 그리고 `0 1 2`
정답
@@ -94,10 +94,10 @@ shape.diameter();
shape.perimeter();
```
-- A: `20` 과 `62.83185307179586`
-- B: `20` 과 `NaN`
-- C: `20` 과 `63`
-- D: `NaN` 과 `63`
+- A: `20` 그리고 `62.83185307179586`
+- B: `20` 그리고 `NaN`
+- C: `20` 그리고 `63`
+- D: `NaN` 그리고 `63`
정답
@@ -122,9 +122,9 @@ shape.perimeter();
!"Lydia";
```
-- A: `1` 과 `false`
-- B: `false` 와 `NaN`
-- C: `false` 와 `false`
+- A: `1` 그리고 `false`
+- B: `false` 그리고 `NaN`
+- C: `false` 그리고 `false`
정답
@@ -190,7 +190,7 @@ console.log(d.greeting);
```
- A: `Hello`
-- B: `Hey`
+- B: `Hey!`
- C: `undefined`
- D: `ReferenceError`
- E: `TypeError`
@@ -235,7 +235,7 @@ console.log(b === c);
#### 정답: C
-`new Number()`는, 내장 함수 생성자에요. 숫자처럼 보이지만, 실제로는 숫자가 아니에요: 많은 추가 특징이 있고 그것은 객체에요.
+`new Number()`는, 내장 함수 생성자에요. 숫자처럼 보이지만, 실제로는 숫자가 아니에요: 많은 추가 특성이 있고 그것은 객체에요.
`==`연산자를 사용할 때, 그건 같은 _값_ 을 가지고 있는지 여부만 확인해요. 그것들은 모두`3`의 값을 가지고 있으므로, `true`를 리턴해요.
@@ -328,9 +328,9 @@ bark.animal = "dog";
#### 정답: A
JavaScript에서는 가능해요, 함수는 객체이기 때문이에요!
-(프리미티브형 이외는 모두 객체에요)
+(프리미티브형 이외는 모두 객체)
-함수는 특별한 종류의 객체에요. 자신이 쓴 코드는 실제 함수가 아니에요. 함수는 속성을 가진 객체에요. 이 속성은 호출이 가능해요.
+함수는 특별한 종류의 객체에요. 당신이 쓴 코드는 실제 함수가 아니에요. 함수는 속성을 가진 객체에요. 이 속성은 호출이 가능해요.
@@ -363,7 +363,7 @@ console.log(member.getFullName());
#### 정답: A
-You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all objects at once, you have to use the prototype instead. So in this case,
+보통의 객체처럼 생성자에는 속성을 추가할 수 없어요. 한 번에 모든 객체에 기능을 추가하고 싶다면, 프로토 타입을 사용해야 해요. 그래서 이 경우에,
```js
Person.prototype.getFullName = function() {
@@ -371,7 +371,7 @@ Person.prototype.getFullName = function() {
};
```
-would have made `member.getFullName()` work. Why is this beneficial? Say that we added this method to the constructor itself. Maybe not every `Person` instance needed this method. This would waste a lot of memory space, since they would still have that property, which takes of memory space for each instance. Instead, if we only add it to the prototype, we just have it at one spot in memory, yet they all have access to it!
+`member.getFullName()`은 작동되요. 이것은 왜 유익할까요? 이 메소드를 생성자 자체에 추가했다고 할게요. 아마도 모든 `Person` 인스턴스는 이 메소드를 필요로 하지 않을 수도 있어요. 그 경우 그들은 아직 속성을 갖고, 각각의 인스턴스를 위해 메모리 공간을 소비하기 때문에, 많은 메모리 공간을 낭비하게 되요. 대신에, 프로토타입을 추가하는 것만으로, 메모리의 한 지점을 가지지만, 모든 것들은 그것에 접근 할 수 있어요.
@@ -393,26 +393,26 @@ console.log(lydia);
console.log(sarah);
```
-- A: `Person {firstName: "Lydia", lastName: "Hallie"}` and `undefined`
-- B: `Person {firstName: "Lydia", lastName: "Hallie"}` and `Person {firstName: "Sarah", lastName: "Smith"}`
-- C: `Person {firstName: "Lydia", lastName: "Hallie"}` and `{}`
-- D:`Person {firstName: "Lydia", lastName: "Hallie"}` and `ReferenceError`
+- A: `Person {firstName: "Lydia", lastName: "Hallie"}` 그리고 `undefined`
+- B: `Person {firstName: "Lydia", lastName: "Hallie"}` 그리고 `Person {firstName: "Sarah", lastName: "Smith"}`
+- C: `Person {firstName: "Lydia", lastName: "Hallie"}` 그리고 `{}`
+- D:`Person {firstName: "Lydia", lastName: "Hallie"}` 그리고 `ReferenceError`
정답
#### 정답: A
-For `sarah`, we didn't use the `new` keyword. When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
+`sarah`를 위해, `new`키워드를 사용하지 않았어요. `new`를 사용한 경우, 이것은 우리가 만든 새로운 빈 객체를 참조해요. 그러나, `new`를 추가하지 않으면 **전역변수**를 참조하게 되요!
-We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smith"`. What we actually did, is defining `global.firstName = 'Sarah'` and `global.lastName = 'Smith'`. `sarah` itself is left `undefined`.
+`this.firstName`에 `"Sarah"`을 대입하고, `this.lastName`에 `"Smith"`을 대입 했다고 말했었어요. (그렇지만) 우리는 실제로, `global.firstName = 'Sarah'` 그리고 `global.lastName = 'Smith'`를 정의한거에요. `sarah` 자체는 `undefined`로 남아있어요.
---
-###### 13. What are the three phases of event propagation?
+###### 13. 이벤트 전달의 3단계는 무엇일까요?
- A: Target > Capturing > Bubbling
- B: Bubbling > Target > Capturing
@@ -424,7 +424,7 @@ We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smit
#### 정답: D
-During the **capturing** phase, the event goes through the ancestor elements down to the target element. It then reaches the **target** element, and **bubbling** begins.
+**capturing** 단계 동안에, 이벤트는 조상요소를 거쳐 목표 요소까지 내려가요. 그런 다음 **target** 요소에 도달하고, **bubbling**이 시작되요.
@@ -433,7 +433,7 @@ During the **capturing** phase, the event goes through the ancestor elements dow
---
-###### 14. All object have prototypes.
+###### 14. 모든 객체는 프로토 타입을 가져요.
- A: true
- B: false
@@ -443,7 +443,7 @@ During the **capturing** phase, the event goes through the ancestor elements dow
#### 정답: B
-All objects have prototypes, except for the **base object**. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
+**기본객체**를 제외한, 모든 객체는 프로포타입을 가져요. 기본객체는 `.toString`와 같은 몇개의 메소드와 속성에 접근할 수 있어요. 이것이 내장 JavaScript 메소드를 사용할 수 있는 이유죠! 이러한 모든 메소드는 프로토 타입에서 이용 할 수 있어요. JavaScript가 당신의 객체를 직접 찾을 수 없더라도, 당신이 접근 할 수 있도록, 프로토타입 체인으로 내려가서 찾을거에요.
@@ -470,9 +470,9 @@ sum(1, "2");
#### 정답: C
-JavaScript is a **dynamically typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
+JavaScript는 **동적으로 만들어진 언어**에요: 특정변수가 어떤 타입인지 지정하지 않아요. 변수는 당신이 모르는 사이에 자동으로 다른 타입으로 변환 될 수 있는데, 이걸 _암묵적 타입 변환_ 이라고 불러요. **Coercion**은 하나의 타입을 다른 타입으로 변환하는 거에요.
-In this example, JavaScript converts the number `1` into a string, in order for the function to make sense and return a value. During the addition of a numeric type (`1`) and a string type (`'2'`), the number is treated as a string. We can concatenate strings like `"Hello" + "World"`, so what's happening here is `"1" + "2"` which returns `"12"`.
+이 예제에서, 함수가 이해하고 값을 리턴하도록, JavaScript는 숫자 `1`을 문자열로 변환해요. 수형 (`1`)와 문자열형 (`'2'`)의 추가 중에는, 숫자는 문자열로 취급되요. `"Hello" + "World"`처럼 문자열을 연결할 수 있어요, 따라서 여기 `"1" + "2"`는 `"12"`을 리턴하는 일이 발생해요.
@@ -498,17 +498,17 @@ console.log(number);
#### 정답: C
-The **postfix** unary operator `++`:
+**접미사** 단항연산자 `++`:
-1. Returns the value (this returns `0`)
-2. Increments the value (number is now `1`)
+1. 값 리턴 (이것은 `0`을 리턴해요)
+2. 값 증가 (number는 지금 `1`이에요)
-The **prefix** unary operator `++`:
+**접두사** 단항연산자 `++`:
-1. Increments the value (number is now `2`)
-2. Returns the value (this returns `2`)
+1. 값 증가 (number는 지금 `2`이에요)
+2. 값 리턴 (이것은 `2`을 리턴해요)
-This returns `0 2 2`.
+이건 `0 2 2`을 리턴해요.
@@ -539,7 +539,7 @@ getPersonInfo`${person} is ${age} years old`;
#### 정답: B
-If you use tagged template literals, the value of the first argument is always an array of the string values. The remaining arguments get the values of the passed expressions!
+태그드 템플릿 리터럴을 사용하는 경우, 첫번재 인수의 값은 항상 문자열 값의 배열이에요. 나머지 인수는 식을 통과한 값을 얻게 되요.
@@ -571,11 +571,11 @@ checkAge({ age: 18 });
#### 정답: C
-When testing equality, primitives are compared by their _value_, while objects are compared by their _reference_. JavaScript checks if the objects have a reference to the same location in memory.
+동등성을 테스트할 때, 프리미티브는 그 _값_ 에 따라 비교되며, 객체는 그들의 _참조_ 에 따라 비교되요. JavaScript 객체가 메모리내의 같은 장소를 참조하고 있는지 여부를 확인해요.
-The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
+비교하고 있는 두개의 객체는 그것이 없어요: 파라미터로 전달된 객체와 동등성을 확인하기 위해 사용한 객체는 메모리 내의 다른 장소를 참조해요.
-This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }` return `false`.
+이것이 `{ age: 18 } === { age: 18 }` 그리고 `{ age: 18 } == { age: 18 }` 두개 다 `false`를 리턴하는 이유죠.
@@ -602,7 +602,7 @@ getAge(21);
#### 정답: C
-The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
+스프레드 연산자 (`...args`.)는 인수를 가진 배열을 리턴해요. 배열은 객체이므로, `typeof args`는 `"object"`를 리턴해요.
@@ -631,14 +631,14 @@ getAge();
#### 정답: C
-With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. If we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
+`"use strict"`을 사용하면, 실수로 전역 변수를 선언하지 않게 할 수 있어요. `age`이라는 변수를 선언한적이 전혀없고, `"use strict"`을 사용하고 있으므로, 참조 에러를 던지게 될거에요. 만약 `"use strict"`을 사용하지 않았다면, 이건 작동할거에요, `age` 속성이 전역 객체에 추가된 것이기 때문이죠.
---
-###### 21. What's value of `sum`?
+###### 21. `sum`의 값은 무엇일까요?
```javascript
const sum = eval("10*10+5");
From 590cdc939ac97c68ab4f0dd5b201af8904c2d52b Mon Sep 17 00:00:00 2001
From: panicdragon
Date: Mon, 24 Jun 2019 02:18:19 +0900
Subject: [PATCH 068/881] fix typo Promice to Promise
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 3eb7e7e7..b24516df 100644
--- a/README.md
+++ b/README.md
@@ -1357,7 +1357,7 @@ Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
#### Answer: B
-When we pass multiple promises to the `Promice.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged.
+When we pass multiple promises to the `Promise.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged.
From 3cf91a7b5d22fa69d997e7be9623d49cfc6e6e14 Mon Sep 17 00:00:00 2001
From: Lydia
Date: Sun, 23 Jun 2019 23:39:55 +0200
Subject: [PATCH 069/881] Fix question 34
---
README.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README.md b/README.md
index 51d89179..3b43f55e 100644
--- a/README.md
+++ b/README.md
@@ -1042,7 +1042,6 @@ typeof sayHi();
The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
-
From 026438386c1c7af2bd78cb82223312c67f128036 Mon Sep 17 00:00:00 2001
From: Lydia
Date: Sun, 23 Jun 2019 23:50:57 +0200
Subject: [PATCH 070/881] Clarify question 14
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 3b43f55e..287aec6f 100644
--- a/README.md
+++ b/README.md
@@ -445,7 +445,7 @@ During the **capturing** phase, the event goes through the ancestor elements dow
#### Answer: B
-All objects have prototypes, except for the **base object**. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
+All objects have prototypes, except for the **base object**. The base object is the object created by the user, or an object that is created using the `new` keyword. The base object has access to some methods and properties, such as `.toString`. This is the reason why you can use built-in JavaScript methods! All of such methods are available on the prototype. Although JavaScript can't find it directly on your object, it goes down the prototype chain and finds it there, which makes it accessible for you.
From 77bb0aefadb7e425ed4ff7cbea808fc0f5c06c29 Mon Sep 17 00:00:00 2001
From: Ihor Sychevskyi <26163841+Arhell@users.noreply.github.com>
Date: Mon, 24 Jun 2019 01:41:56 +0300
Subject: [PATCH 071/881] Remove double delimiter, UA
---
README-ua_UA.md | 2 --
1 file changed, 2 deletions(-)
diff --git a/README-ua_UA.md b/README-ua_UA.md
index 0a1a935e..c14d922e 100644
--- a/README-ua_UA.md
+++ b/README-ua_UA.md
@@ -174,8 +174,6 @@ JavaScript інтерпретує (або розпаковує) оператор
---
----
-
###### 6. Що буде в консолі?
```javascript
From 45bc4b6aa02f926975b05aab9077f6548f012985 Mon Sep 17 00:00:00 2001
From: Guilherme Nogara
Date: Sun, 23 Jun 2019 21:35:36 -0300
Subject: [PATCH 072/881] Link original README.md
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
E mais um caso de termo usando `` e não era seguido por espaço quando no meio da sentença.
---
README.md | 1 +
README_pt_BR.md | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index f1d14d90..fc9f42c7 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ The answers are in the collapsed sections below the questions, simply click on t
[Western Balkan](./README-bs.md)
[Deutsch](./README-de_DE.md)
[Tiếng Việt](./README-vi.md)
+[Português Brasil](./README_pt_BR.md)
---
diff --git a/README_pt_BR.md b/README_pt_BR.md
index b90a88d8..9b9d5c25 100644
--- a/README_pt_BR.md
+++ b/README_pt_BR.md
@@ -1009,7 +1009,7 @@ sayHi.bind(person, 21);
#### Resposta: D
-Com ambos, podemos passar o objeto que queremos que o `this`faça referência. Contudo, `.call` é _executado imediatamente_!
+Com ambos, podemos passar o objeto que queremos que o `this` faça referência. Contudo, `.call` é _executado imediatamente_!
`.bind.` retorna uma _cópia_ da função, mas com seu contexto vinculado à cópia. E não é executado imediatamente.
From ca8df9197c84e141431773e7192810244a2ca4d6 Mon Sep 17 00:00:00 2001
From: Shyam Chen
Date: Mon, 24 Jun 2019 09:43:47 +0800
Subject: [PATCH 073/881] fix: duplicate link
---
README.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README.md b/README.md
index 287aec6f..91d1abbb 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,6 @@ The answers are in the collapsed sections below the questions, simply click on t
List of available languages:
* [中文版本](./README-zh_CN.md)
* [Versión en español](./README-ES.md)
-* [中文版本](./README-zh_CN.md)
* [日本語](./README-ja_JA.md)
* [Русский](./README_ru-RU.md)
* [Western Balkan](./README-bs_BS.md)
From 1272dcbad19da871dcb4afa5eb1b25cebd0f584d Mon Sep 17 00:00:00 2001
From: Azarias Boutin
Date: Mon, 24 Jun 2019 06:17:14 +0200
Subject: [PATCH 074/881] Remove console.log for giveLydiaPizza
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 5b742ac1..0411ce54 100644
--- a/README.md
+++ b/README.md
@@ -804,7 +804,7 @@ String.prototype.giveLydiaPizza = () => {
const name = "Lydia";
-console.log(name.giveLydiaPizza());
+name.giveLydiaPizza();
```
- A: `"Just give Lydia pizza already!"`
From 6118d053b79a5b94ea01a7d5e212550d52911139 Mon Sep 17 00:00:00 2001
From: Dima Yavorskiy <33015386+yavorskiydima@users.noreply.github.com>
Date: Mon, 24 Jun 2019 10:23:02 +0500
Subject: [PATCH 075/881] ru translate 44-50 question
---
README_ru-RU.md | 360 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 360 insertions(+)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index d0dbeda4..233f3f9b 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -1295,3 +1295,363 @@ setInterval(() => console.log("Hi"), 1000);
+
+---
+
+###### 44. Каким будет результат?
+
+```javascript
+function* generator(i) {
+ yield i;
+ yield i * 2;
+}
+
+const gen = generator(10);
+
+console.log(gen.next().value);
+console.log(gen.next().value);
+```
+
+- A: `[0, 10], [10, 20]`
+- B: `20, 20`
+- C: `10, 20`
+- D: `0, 10 and 10, 20`
+
+Ответ
+
+
+#### Ответ: C
+
+Обычные функции не могут быть остановлены на полпути после вызова. Однако функцию генератор можно "остановить" на полпути, а затем продолжить с того места, где она остановилась. Каждый раз, когда в функции-генераторе встречает ключевое слово `yield`, функция возвращает значение, указанное после него. Обратите внимание, что функция генератора в этом случае не _return_ значение, оно _yields_ значение.
+
+Сначала мы инициализируем функцию генератор с `i`, равным` 10`. Мы вызываем функцию генератор, используя метод `next ()`. Когда мы в первый раз вызываем функцию генератора, `i` равно` 10`. Он встречает первое ключевое слово `yield`, получая значение `i`. Генератор теперь "приостановлен", и `10` выводится в консоль.
+
+Затем мы снова вызываем функцию с помощью метода `next ()`. Она запускается с того места, где остановилась ранее, все еще с `i`, равным` 10`. Теперь он встречает следующее ключевое слово `yield` и возвращает `i * 2`. `i` равно` 10`, поэтому он возвращает `10 * 2`, то есть` 20`. Это приводит к 10, 20.
+
+
+
+
+---
+
+###### 45. Каким будет результат?
+
+```javascript
+const firstPromise = new Promise((res, rej) => {
+ setTimeout(res, 500, "один");
+});
+
+const secondPromise = new Promise((res, rej) => {
+ setTimeout(res, 100, "два");
+});
+
+Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
+```
+
+- A: `"один"`
+- B: `"два"`
+- C: `"два" "один"`
+- D: `"один" "два"`
+
+Ответ
+
+
+#### Ответ: B
+
+Когда мы передаем несколько промисов методу `Promise.race`, он разрешает/отклоняет _первый_ промис, который разрешает/отклоняет. В метод `setTimeout` мы передаем таймер: 500 мс для первого промиса (`firstPromise`) и 100 мс для второго промиса (`secondPromise`). Это означает, что `secondPromise` разрешается первым со значением `'два'`. `res` теперь содержит значение`'два'`, которое выводиться в консоль.
+
+
+
+
+---
+
+###### 46. Каким будет результат?
+
+```javascript
+let person = { name: "Lydia" };
+const members = [person];
+person = null;
+
+console.log(members);
+```
+
+- A: `null`
+- B: `[null]`
+- C: `[{}]`
+- D: `[{ name: "Lydia" }]`
+
+Ответ
+
+
+#### Ответ: D
+
+Сначала мы объявляем переменную `person` со значением объекта, у которого есть свойство` name`.
+
+
+
+Затем мы объявляем переменную с именем `members`. Мы устанавливаем первый элемент этого массива равным значению переменной `person`. Объекты взаимодействуют посредством _ссылок_ при установке их равными друг другу. Когда вы назначаете ссылку из одной переменной в другую, вы создаете _копию_ этой ссылки. (обратите внимание, что у них _не одинаковые_ ссылки!)
+
+
+
+Затем мы присваеваем переменной `person` значение `null`.
+
+
+
+Мы изменили только значение переменной `person`, а не первый элемент в массиве, поскольку этот элемент имеет другую (скопированную) ссылку на объект. Первый элемент в `members` по-прежнему содержит ссылку на исходный объект. Когда мы выводим в консоль массив `members`, первый элемент по-прежнему содержит значение объекта, который выводится в консоль.
+
+
+
+
+---
+
+###### 47. Каким будет результат?
+
+```javascript
+const person = {
+ name: "Lydia",
+ age: 21
+};
+
+for (const item in person) {
+ console.log(item);
+}
+```
+
+- A: `{ name: "Lydia" }, { age: 21 }`
+- B: `"name", "age"`
+- C: `"Lydia", 21`
+- D: `["name", "Lydia"], ["age", 21]`
+
+Ответ
+
+
+#### Ответ: B
+
+С помощью цикла `for-in` мы можем перебирать ключи объекта, в данном случае `name` и `age`. Под капотом ключи объекта являются строками (если они не являются Symbol). В каждом цикле мы устанавливаем значение `item` равным текущему ключу, по которому он перебирается. Сначала, `item` равен `name`, и выводится в консоль. Затем `item` равен `age`, который выводится в консоль.
+
+
+
+
+---
+
+###### 48. Каким будет результат?
+
+```javascript
+console.log(3 + 4 + "5");
+```
+
+- A: `"345"`
+- B: `"75"`
+- C: `12`
+- D: `"12"`
+
+Ответ
+
+
+#### Ответ: B
+
+Operator associativity is the order in which the compiler evaluates the expressions, either left-to-right or right-to-left. This only happens if all operators have the _same_ precedence. We only have one type of operator: `+`. For addition, the associativity is left-to-right.
+
+Ассоциативность операторов - это порядок, в котором компилятор оценивает выражения, слева направо или справа налево. Это происходит только в том случае, если все операторы имеют _одинаковый_ приоритет. У нас есть только один тип оператора: `+`. Кроме того, ассоциативность слева направо.
+
+`3 + 4` оценивается первым. Это приводит к числу `7`.
+
+`7 + '5'` приводит к `"75"` из-за принуждения. JavaScript преобразует число `7` в строку, см. вопрос 15. Мы можем объединить две строки, используя оператор `+`. `"7" + "5"` приводит к `"75"`.
+
+
+
+
+---
+
+###### 49. Какое значение `num`?
+
+```javascript
+const num = parseInt("7*6", 10);
+```
+
+- A: `42`
+- B: `"42"`
+- C: `7`
+- D: `NaN`
+
+Ответ
+
+
+#### Ответ: C
+
+Только первые числа в строке возвращаются. На основе _системы счисления_ (второй аргумент, чтобы указать, к какому типу чисел мы хотим его анализировать: основание 10, шестнадцатеричное, восьмеричное, двоичное и т.д.), `ParseInt` проверяет, являются ли символы в строке допустимыми. Как только он встречает символ, который не является допустимым числом в основании, он прекращает синтаксический анализ и игнорирует следующие символы.
+
+`*` не является допустимым числом. Он только разбирает `"7"` в десятичную `7`. `num` теперь содержит значение` 7`.
+
+
+
+
+---
+
+###### 50. Каким будет результат?
+
+```javascript
+[1, 2, 3].map(num => {
+ if (typeof num === "number") return;
+ return num * 2;
+});
+```
+
+- A: `[]`
+- B: `[null, null, null]`
+- C: `[undefined, undefined, undefined]`
+- D: `[ 3 x empty ]`
+
+Ответ
+
+
+#### Ответ: C
+
+При использовании метода map, значение `num` равно элементу, над которым он в данный момент зацикливается. В этом случае элементы являются числами, поэтому условие оператора if `typeof num === "number"` возвращает `true`. Функция map создает новый массив и вставляет значения, возвращаемые функцией.
+
+Однако мы не возвращаем значение. Когда мы не возвращаем значение из функции, функция возвращает значение `undefined`. Для каждого элемента в массиве вызывается функциональный блок, поэтому для каждого элемента мы возвращаем "undefined".
+
+
+
+
+---
+
+###### 51. What's the output?
+
+```javascript
+function getInfo(member, year) {
+ member.name = "Lydia";
+ year = 1998;
+}
+
+const person = { name: "Sarah" };
+const birthYear = "1997";
+
+getInfo(person, birthYear);
+
+console.log(person, birthYear);
+```
+
+- A: `{ name: "Lydia" }, "1997"`
+- B: `{ name: "Sarah" }, "1998"`
+- C: `{ name: "Lydia" }, "1998"`
+- D: `{ name: "Sarah" }, "1997"`
+
+Answer
+
+
+#### Answer: A
+
+Arguments are passed by _value_, unless their value is an object, then they're passed by _reference_. `birthYear` is passed by value, since it's a string, not an object. When we pass arguments by value, a _copy_ of that value is created (see question 46).
+
+The variable `birthYear` has a reference to the value `"1997"`. The argument `year` also has a reference to the value `"1997"`, but it's not the same value as `birthYear` has a reference to. When we update the value of `year` by setting `year` equal to `"1998"`, we are only updating the value of `year`. `birthYear` is still equal to `"1997"`.
+
+The value of `person` is an object. The argument `member` has a (copied) reference to the _same_ object. When we modify a property of the object `member` has a reference to, the value of `person` will also be modified, since they both have a reference to the same object. `person`'s `name` property is now equal to the value `"Lydia"`
+
+
+
+
+---
+
+###### 52. What's the output?
+
+```javascript
+function greeting() {
+ throw "Hello world!";
+}
+
+function sayHi() {
+ try {
+ const data = greeting();
+ console.log("It worked!", data);
+ } catch (e) {
+ console.log("Oh no an error!", e);
+ }
+}
+
+sayHi();
+```
+
+- A: `"It worked! Hello world!"`
+- B: `"Oh no an error: undefined`
+- C: `SyntaxError: can only throw Error objects`
+- D: `"Oh no an error: Hello world!`
+
+Answer
+
+
+#### Answer: D
+
+With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world'`.
+
+With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world'`. `e` is now equal to that string, which we log. This results in `'Oh an error: Hello world'`.
+
+
+
+
+---
+
+###### 53. What's the output?
+
+```javascript
+function Car() {
+ this.make = "Lamborghini";
+ return { make: "Maserati" };
+}
+
+const myCar = new Car();
+console.log(myCar.make);
+```
+
+- A: `"Lamborghini"`
+- B: `"Maserati"`
+- C: `ReferenceError`
+- D: `TypeError`
+
+Answer
+
+
+#### Answer: B
+
+When you return a property, the value of the property is equal to the _returned_ value, not the value set in the constructor function. We return the string `"Maserati"`, so `myCar.make` is equal to `"Maserati"`.
+
+
+
+
+---
+
+###### 54. What's the output?
+
+```javascript
+(() => {
+ let x = (y = 10);
+})();
+
+console.log(typeof x);
+console.log(typeof y);
+```
+
+- A: `"undefined", "number"`
+- B: `"number", "number"`
+- C: `"object", "number"`
+- D: `"number", "undefined"`
+
+Answer
+
+
+#### Answer: A
+
+`let x = y = 10;` is actually shorthand for:
+
+```javascript
+y = 10;
+let x = y;
+```
+
+When we set `y` equal to `10`, we actually add a property `y` to the global object (`window` in browser, `global` in Node). In a browser, `window.y` is now equal to `10`.
+
+Then, we declare a variable `x` with the value of `y`, which is `10`. Variables declared with the `let` keyword are _block scoped_, they are only defined within the block they're declared in; the immediately-invoked function (IIFE) in this case. When we use the `typeof` operator, the operand `x` is not defined: we are trying to access `x` outside of the block it's declared in. This means that `x` is not defined. Values who haven't been assigned a value or declared are of type `"undefined"`. `console.log(typeof x)` returns `"undefined"`.
+
+However, we created a global variable `y` when setting `y` equal to `10`. This value is accessible anywhere in our code. `y` is defined, and holds a value of type `"number"`. `console.log(typeof y)` returns `"number"`.
+
+
+
\ No newline at end of file
From 5f6887f0c8a87e7d89919ba08fe96c54e8ae9ed7 Mon Sep 17 00:00:00 2001
From: Dima Yavorskiy <33015386+yavorskiydima@users.noreply.github.com>
Date: Mon, 24 Jun 2019 10:42:24 +0500
Subject: [PATCH 076/881] ru translate 50-54
---
README_ru-RU.md | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index 233f3f9b..f4ee0126 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -1515,7 +1515,7 @@ const num = parseInt("7*6", 10);
---
-###### 51. What's the output?
+###### 51. Каким будет результат?
```javascript
function getInfo(member, year) {
@@ -1536,23 +1536,23 @@ console.log(person, birthYear);
- C: `{ name: "Lydia" }, "1998"`
- D: `{ name: "Sarah" }, "1997"`
-Answer
+Ответ
-#### Answer: A
+#### Ответ: A
-Arguments are passed by _value_, unless their value is an object, then they're passed by _reference_. `birthYear` is passed by value, since it's a string, not an object. When we pass arguments by value, a _copy_ of that value is created (see question 46).
+Аргументы передаются _значением_, если их значение не является объектом, то они передаются _ссылкой_. `birthYear` передается по значению, поскольку это строка, а не объект. Когда мы передаем аргументы по значению, создается _копия_ этого значения (см. вопрос 46).
-The variable `birthYear` has a reference to the value `"1997"`. The argument `year` also has a reference to the value `"1997"`, but it's not the same value as `birthYear` has a reference to. When we update the value of `year` by setting `year` equal to `"1998"`, we are only updating the value of `year`. `birthYear` is still equal to `"1997"`.
+Переменная `birthYear` имеет ссылку на значение `"1997"`. Аргумент `year` также имеет ссылку на значение` "1997" `, но это не то же самое значение, на которое имеется ссылка для `birthYear`. Когда мы обновляем значение `year`, устанавливая `year` равным `"1998"`, мы обновляем только значение `year`. `birthYear` по-прежнему равно `"1997"`.
-The value of `person` is an object. The argument `member` has a (copied) reference to the _same_ object. When we modify a property of the object `member` has a reference to, the value of `person` will also be modified, since they both have a reference to the same object. `person`'s `name` property is now equal to the value `"Lydia"`
+Значение `person` является объектом. Аргумент `member` имеет (скопированную) ссылку на _тот же_ объект. Когда мы изменяем свойство объекта, на который `member` ссылается, значение `person` также будет изменено, поскольку они оба имеют ссылку на один и тот же объект. Свойство `name` объекта `person` теперь равно значению `"Lydia"`.
---
-###### 52. What's the output?
+###### 52. Каким будет результат?
```javascript
function greeting() {
@@ -1576,21 +1576,21 @@ sayHi();
- C: `SyntaxError: can only throw Error objects`
- D: `"Oh no an error: Hello world!`
-Answer
+Ответ
-#### Answer: D
+#### Ответ: D
-With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world'`.
+С помощью оператора `throw` мы можем создавать собственные ошибки. С этим оператором вы можете генерировать исключения. Исключением может быть строка, число, логическое значение или объект. В этом случае нашим исключением является строка `'Hello world'`.
-With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world'`. `e` is now equal to that string, which we log. This results in `'Oh an error: Hello world'`.
+С помощью оператора `catch` мы можем указать, что делать, если в блоке` try` выдается исключение. Исключение: строка `'Hello world'`. `e` теперь равно той строке, которую мы записываем. Это приводит к `'Oh error: Hello world'`.
---
-###### 53. What's the output?
+###### 53. Каким будет результат?
```javascript
function Car() {
@@ -1607,19 +1607,19 @@ console.log(myCar.make);
- C: `ReferenceError`
- D: `TypeError`
-Answer
+Ответ
-#### Answer: B
+#### Ответ: B
-When you return a property, the value of the property is equal to the _returned_ value, not the value set in the constructor function. We return the string `"Maserati"`, so `myCar.make` is equal to `"Maserati"`.
+Когда вы возвращаете свойство, значение свойства равно _возвращаемому_ значению, а не значению, установленному в функции конструктора. Мы возвращаем строку `"Maserati"`, поэтому `myCar.make` равно `"Maserati"`.
---
-###### 54. What's the output?
+###### 54. Каким будет результат?
```javascript
(() => {
@@ -1635,23 +1635,23 @@ console.log(typeof y);
- C: `"object", "number"`
- D: `"number", "undefined"`
-Answer
+Ответ
-#### Answer: A
+#### Ответ: A
-`let x = y = 10;` is actually shorthand for:
+`let x = y = 10;` на самом деле является сокращением для:
```javascript
y = 10;
let x = y;
```
-When we set `y` equal to `10`, we actually add a property `y` to the global object (`window` in browser, `global` in Node). In a browser, `window.y` is now equal to `10`.
+Когда мы устанавливаем `y` равным` 10`, мы фактически добавляем свойство `y` к глобальному объекту (`window` в браузере, `global` в Node). В браузере `window.y` теперь равен` 10`.
-Then, we declare a variable `x` with the value of `y`, which is `10`. Variables declared with the `let` keyword are _block scoped_, they are only defined within the block they're declared in; the immediately-invoked function (IIFE) in this case. When we use the `typeof` operator, the operand `x` is not defined: we are trying to access `x` outside of the block it's declared in. This means that `x` is not defined. Values who haven't been assigned a value or declared are of type `"undefined"`. `console.log(typeof x)` returns `"undefined"`.
+Затем мы объявляем переменную `x` со значением` y`, которое равно `10`. Переменные, объявленные с ключевым словом `let`, имею _блочную видимость_, они определены только в блоке, в котором они объявлены; немедленно вызванная функция (IIFE) в этом случае. Когда мы используем оператор `typeof`, операнд` x` не определен: мы пытаемся получить доступ к `x` вне блока, в котором он объявлен. Это означает, что` x` не определен. Значения, которым не присвоено или не объявлено значение, имеют тип `"undefined"`. `console.log(typeof x)` возвращает `"undefined"`.
-However, we created a global variable `y` when setting `y` equal to `10`. This value is accessible anywhere in our code. `y` is defined, and holds a value of type `"number"`. `console.log(typeof y)` returns `"number"`.
+Однако мы создали глобальную переменную `y`, установив `y` равным `10`. Это значение доступно в любом месте нашего кода. `y` определен и содержит значение типа `"number"`. `console.log(typeof y)` возвращает `"number"`.
\ No newline at end of file
From b82ac5b5865b859ac880417993f65847b851d04e Mon Sep 17 00:00:00 2001
From: Dima Yavorskiy <33015386+yavorskiydima@users.noreply.github.com>
Date: Mon, 24 Jun 2019 10:46:14 +0500
Subject: [PATCH 077/881] fix typo
---
README_ru-RU.md | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index f4ee0126..f0ab0df3 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -1357,7 +1357,7 @@ Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
#### Ответ: B
-Когда мы передаем несколько промисов методу `Promise.race`, он разрешает/отклоняет _первый_ промис, который разрешает/отклоняет. В метод `setTimeout` мы передаем таймер: 500 мс для первого промиса (`firstPromise`) и 100 мс для второго промиса (`secondPromise`). Это означает, что `secondPromise` разрешается первым со значением `'два'`. `res` теперь содержит значение`'два'`, которое выводиться в консоль.
+Когда мы передаем несколько промисов методу `Promise.race`, он разрешает/отклоняет _первый_ промис, который разрешает/отклоняет. В метод `setTimeout` мы передаем таймер: 500 мс для первого промиса (`firstPromise`) и 100 мс для второго промиса (`secondPromise`). Это означает, что `secondPromise` разрешается первым со значением `'два'`. `res` теперь содержит значение `'два'`, которое выводиться в консоль.
@@ -1392,7 +1392,7 @@ console.log(members);
-Затем мы присваеваем переменной `person` значение `null`.
+Затем мы присваиваем переменной `person` значение `null`.
@@ -1449,8 +1449,6 @@ console.log(3 + 4 + "5");
#### Ответ: B
-Operator associativity is the order in which the compiler evaluates the expressions, either left-to-right or right-to-left. This only happens if all operators have the _same_ precedence. We only have one type of operator: `+`. For addition, the associativity is left-to-right.
-
Ассоциативность операторов - это порядок, в котором компилятор оценивает выражения, слева направо или справа налево. Это происходит только в том случае, если все операторы имеют _одинаковый_ приоритет. У нас есть только один тип оператора: `+`. Кроме того, ассоциативность слева направо.
`3 + 4` оценивается первым. Это приводит к числу `7`.
@@ -1508,7 +1506,7 @@ const num = parseInt("7*6", 10);
При использовании метода map, значение `num` равно элементу, над которым он в данный момент зацикливается. В этом случае элементы являются числами, поэтому условие оператора if `typeof num === "number"` возвращает `true`. Функция map создает новый массив и вставляет значения, возвращаемые функцией.
-Однако мы не возвращаем значение. Когда мы не возвращаем значение из функции, функция возвращает значение `undefined`. Для каждого элемента в массиве вызывается функциональный блок, поэтому для каждого элемента мы возвращаем "undefined".
+Однако мы не возвращаем значение. Когда мы не возвращаем значение из функции, функция возвращает значение `undefined`. Для каждого элемента в массиве вызывается функциональный блок, поэтому для каждого элемента мы возвращаем `undefined`.
From 6507fdac902c12abe2e50d8df004c0d91569a343 Mon Sep 17 00:00:00 2001
From: TuanTV
Date: Mon, 24 Jun 2019 15:13:51 +0700
Subject: [PATCH 078/881] translate and change content vietnamese
---
README-vi.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/README-vi.md b/README-vi.md
index 5550ec41..55e61bad 100644
--- a/README-vi.md
+++ b/README-vi.md
@@ -1,6 +1,6 @@
# Những câu hỏi JavaScript trình độ Advanced
-Hàng ngày tôi sẽ post các câu hỏi multichoice lên [Instagram](https://www.instagram.com/theavocoder) của tôi và tại đây nữa!
+Hàng ngày tôi sẽ đăng các câu hỏi multichoice lên [Instagram](https://www.instagram.com/theavocoder) của tôi và tại đây nữa!
Các câu hỏi sẽ từ cơ bản đến nâng cao: kiểm tra trình độ JavaScript của bạn, làm mới một chút về kiến thức, hay chuẩn bị cho cuộc phỏng vấn lập trình! :muscle: :rocket: Tôi sẽ cập nhật các câu hỏi mới hàng tuần.
@@ -157,7 +157,7 @@ const mouse = {
#### Đáp án: A
-Trong JavaScript thì tất cả keys của các object đều là string (ngoại trừ khi nó là một Symbol). Dù chúng ta không viết chúng như một string, về cơ bản chúng sẽ luôn được convert sang dạng string.
+Trong JavaScript thì tất cả keys của các object đều là string (ngoại trừ khi nó là một Symbol). Dù chúng ta không viết chúng như một string, về cơ bản chúng sẽ luôn được chuyển sang dạng string.
JavaScript thông dịch (hay unboxes) từng câu lệnh. Khi chúng ta sử dụng cặp dấu ngoặc `[]`, nó sẽ tìm kiếm dấu mở ngoặc đầu tiên `[`, và sẽ tiếp tục tìm kiếm cho tới khi gặp dấu đóng ngoặc `]`. Chỉ khi đó thì câu lệnh mới được thực thi.
@@ -463,7 +463,7 @@ sum(1, "2");
#### Đáp án: C
-JavaScript là một ngôn ngữ **dynamically typed**: chúng ta không khai báo kiểu dữ liệu khi khai báo biến. Giá trị có thể bị tự động convert sang một kiểu dữ liệu khác mà ta không hề hay biết, điều này được gọi là __implicit type coercion_. **Coercion** có nghĩa là convert từ kiểu này sang kiểu khác.
+JavaScript là một ngôn ngữ **dynamically typed**: chúng ta không khai báo kiểu dữ liệu khi khai báo biến. Giá trị có thể bị tự động convert sang một kiểu dữ liệu khác mà ta không hề hay biết, điều này được gọi là _implicit type coercion_. **Coercion** có nghĩa là convert từ kiểu này sang kiểu khác.
Trong ví dụ này, JavaScript sẽ convert số `1` sang dạng string. Mỗi khi ta cộng một số (`1`) với một string (`'2'`), số sẽ luôn được xem như là một string. Kết quả sẽ là một phép nối chuỗi giống như `"Hello" + "World"`, vậy nên `"1" + "2"` sẽ trả về là `"12"`.
@@ -631,7 +631,7 @@ Với `"use strict"`, chúng ta sẽ đảm bảo được rằng ta sẽ không
---
-###### 21. What's value of `sum`?
+###### 21. Giá trị của `sum` là gì?
```javascript
const sum = eval("10*10+5");
@@ -922,7 +922,7 @@ WebAPI không thể thêm thứ gì đó vào stack cho tới khi nó được s
---
-###### 31. What is the event.target when clicking the button?
+###### 31. Giá trị của event.target là gì khi click button?
```html
@@ -951,7 +951,7 @@ Phần tử sâu nhất trong các phần tử lồng nhau sẽ là target của
---
-###### 32. Khi bạn click vào đoạn văn, cái gì sẽ được ghi ra output?
+###### 32. Khi bạn click vào đoạn văn, giá trị của output sẽ là gì?
```html
From 3114326d0b5bc72ea3d8f95fb7754fd02a7d353b Mon Sep 17 00:00:00 2001
From: panicdragon
Date: Mon, 24 Jun 2019 02:06:12 +0900
Subject: [PATCH 079/881] add new questions no.44 ~ no.54 & translate to
japanese
---
README-ja_JA.md | 378 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 378 insertions(+)
diff --git a/README-ja_JA.md b/README-ja_JA.md
index 9ffde70a..155e8969 100644
--- a/README-ja_JA.md
+++ b/README-ja_JA.md
@@ -1333,3 +1333,381 @@ setInterval(() => console.log("Hi"), 1000);
+
+###### 44. 何が出力されるでしょうか?
+
+```javascript
+function* generator(i) {
+ yield i;
+ yield i * 2;
+}
+
+const gen = generator(10);
+
+console.log(gen.next().value);
+console.log(gen.next().value);
+```
+
+- A: `[0, 10], [10, 20]`
+- B: `20, 20`
+- C: `10, 20`
+- D: `0, 10 and 10, 20`
+
+答え
+
+
+#### 答え: C
+
+通常の関数は、呼び出し後に途中で停止することはできません。ただし、ジェネレータ関数は途中で"停止"し、後で停止した場所から続行することができます。
+
+ジェネレータ関数が`yield`キーワードを見つけるたびに、その関数はその後に指定された値を返します。その場合のジェネレータ関数は、値を"返す"わけではないことに注意してください。値を生み出しています。
+
+まず、`i`に`10`を指定してジェネレータ関数を初期化します。次に`next()`メソッドを使用してジェネレータ関数を呼び出します。
+
+最初にジェネレータ関数を呼び出すと、`i`は`10`になり、最初の`yield`キーワードに遭遇します。そこから`i`の値が得られます。ジェネレータは"一時停止"され、`10`がログ出力されます。
+
+それから、`next()`メソッドを使って関数を再度呼び出します。依然として`i`は`10`のまま、以前に停止したところから継続し始めます。
+
+それから次の`yield`キーワードに遭遇し、そこから`i * 2`の値が得られます。`i`は`10`のままなので、`10 * 2`、つまり`20`を返します。なので、`10、20`が返る事になります。
+
+
+
+
+---
+
+###### 45. これは何を返しますか?
+
+```javascript
+const firstPromise = new Promise((res, rej) => {
+ setTimeout(res, 500, "one");
+});
+
+const secondPromise = new Promise((res, rej) => {
+ setTimeout(res, 100, "two");
+});
+
+Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
+```
+
+- A: `"one"`
+- B: `"two"`
+- C: `"two" "one"`
+- D: `"one" "two"`
+
+答え
+
+
+#### 答え: B
+
+複数のプロミスを`Promise.race`メソッドに渡した時、"resolves/rejects"は、"最初"のプロミスの"resolves/rejects"を行います。
+
+`setTimeout`メソッドには、タイマーを渡します: 最初のプロミスには500ms(`firstPromise`)、2番目のプロミスには100ms(`secondPromise`)。
+
+これは、`secondPromise`が最初に`'two'`の値で解決されることを意味します。`res`は`'two'`の値を保持するようになり、ログ出力されます。
+
+
+
+
+---
+
+###### 46. 何が出力されるでしょうか?
+
+```javascript
+let person = { name: "Lydia" };
+const members = [person];
+person = null;
+
+console.log(members);
+```
+
+- A: `null`
+- B: `[null]`
+- C: `[{}]`
+- D: `[{ name: "Lydia" }]`
+
+答え
+
+
+#### 答え: D
+
+まず、`name`プロパティを持つオブジェクトの値を使って、変数`person`を宣言します。
+
+
+
+それから、`members`という変数を宣言します。その配列の最初の要素に、変数`person`の値を代入します。オブジェクトは、互いをイコールで設定すると、「参照」によって相互作用します。
+
+ある変数から別の変数への"参照"を代入すると、その参照の"コピー"が作成されます。 (それらは、"同じ参照"を持っていないことに注意してください!)
+
+
+
+そして、変数`person`を`null`に設定します。
+
+
+
+その要素はオブジェクトへの異なる(コピーされた)参照を持っているので、`person`変数の値を変更するだけで配列の最初の要素は変更されません。 `members`の最初の要素はまだ元のオブジェクトへの参照を保持しています。
+
+`members`配列をログ出力したとき、最初の要素はまだオブジェクトの値を保持しているので、それがログ出力されます。
+
+
+
+
+---
+
+###### 47. 何が出力されるでしょうか?
+
+```javascript
+const person = {
+ name: "Lydia",
+ age: 21
+};
+
+for (const item in person) {
+ console.log(item);
+}
+```
+
+- A: `{ name: "Lydia" }, { age: 21 }`
+- B: `"name", "age"`
+- C: `"Lydia", 21`
+- D: `["name", "Lydia"], ["age", 21]`
+
+答え
+
+
+#### 答え: B
+
+この場合、`for-in`ループを使うと、オブジェクトキーである`name`と`age`の繰り返し処理できます。内部的には、オブジェクトキーは文字列です(シンボルではない場合)。
+
+すべてのループで、`item`の値は反復している現在のキーに設定されます。まず、`item`は`name`が代入され、ログに出力されます。その後、`item`は`age`が代入され、ログに出力されます。
+
+
+
+
+---
+
+###### 48. 何が出力されるでしょうか?
+
+```javascript
+console.log(3 + 4 + "5");
+```
+
+- A: `"345"`
+- B: `"75"`
+- C: `12`
+- D: `"12"`
+
+答え
+
+
+#### 答え: B
+
+演算子結合性は、コンパイラーが式を評価する順序(左から右または右から左)となります。これは、すべての演算子が同じ優先順位を持つ場合にのみ発生します。演算子の種類は1つだけです: `+`。さらに、結合性は左から右です。
+
+`3 + 4`が最初に評価されます。これは数字の`7`になります。
+
+`7 + '5'`は、強制的に`"75"`になります。 JavaScriptでは、数字の`7`を文字列に変換します。質問15を参照してください。2つの文字列を演算子の`+`を使って連結することができます。よって、`"7" + "5"`は、`"75"`になります。
+
+
+
+
+---
+
+###### 49. numの値は何ですか?
+
+```javascript
+const num = parseInt("7*6", 10);
+```
+
+- A: `42`
+- B: `"42"`
+- C: `7`
+- D: `NaN`
+
+答え
+
+
+#### 答え: C
+
+文字列の最初の数字だけが返されます。"基数"(解析する数値の種類を指定するための2番目の引数: 基数10, 16進数, 8進数, 2進数など)に基づいて、`parseInt`は文字列内の文字が有効かどうかをチェックします。基数の中で有効な数字ではない文字に出会うと、構文解析を停止して次の文字を無視します。
+
+`*`は、有効な数字ではありません。`"7"`を、10進数の`7`に解析するだけです。そのままnumは`7`の値を保持します。
+
+
+
+
+---
+
+###### 50. 何が出力されるでしょうか?
+
+```javascript
+[1, 2, 3].map(num => {
+ if (typeof num === "number") return;
+ return num * 2;
+});
+```
+
+- A: `[]`
+- B: `[null, null, null]`
+- C: `[undefined, undefined, undefined]`
+- D: `[ 3 x empty ]`
+
+答え
+
+
+#### 答え: C
+
+配列をマッピングするとき、`num`の値に代入されるのは、ループで渡ってくる要素となります。この場合、要素は数値なので、ifステートメント `typeof num === "number"`の条件は`true`を返します。 map関数は新しい配列を作成して関数から返された値を挿入します。
+
+ただし、値は返されません。関数から値を返さないと、関数は`undefined`を返します。配列内のすべての要素に対して関数ブロックが呼び出されるので、各要素に対して`undefined`を返します。
+
+
+
+
+---
+
+###### 51. 何が出力されるでしょうか?
+
+```javascript
+function getInfo(member, year) {
+ member.name = "Lydia";
+ year = 1998;
+}
+
+const person = { name: "Sarah" };
+const birthYear = "1997";
+
+getInfo(person, birthYear);
+
+console.log(person, birthYear);
+```
+
+- A: `{ name: "Lydia" }, "1997"`
+- B: `{ name: "Sarah" }, "1998"`
+- C: `{ name: "Lydia" }, "1998"`
+- D: `{ name: "Sarah" }, "1997"`
+
+答え
+
+
+#### 答え: A
+
+値がオブジェクトでない限り、引数は"値"によって渡され、その後、"参照"によって渡されます。 `birthYear`はオブジェクトではなく文字列なので、値で渡されます。引数を値で渡すと、その値の"コピー"が作成されます(質問46を参照)。
+
+変数`birthYear`は、値`"1997"`への参照を持ちます。引数`year`は、値`"1997"`も参照していますが、それは`birthYear`が参照しているのと同じ値ではありません。`year`に`"1998"`を代入することによって`year`の値を更新したとしても、`year`の値を更新するだけです。`birthYear`はまだ`"1997"`となります。
+
+`person`の値はオブジェクトです。引数`member`は"同じ"オブジェクトへの(コピーされた)参照を持ちます。
+
+`member`が参照を持つオブジェクトのプロパティを変更すると、`person`の値も変更されます。これらは両方とも同じオブジェクトへの参照を持つからです。`person`の`name`プロパティは、値の`"Lydia"`となりました。
+
+
+
+
+---
+
+###### 52. 何が出力されるでしょうか?
+
+```javascript
+function greeting() {
+ throw "Hello world!";
+}
+
+function sayHi() {
+ try {
+ const data = greeting();
+ console.log("It worked!", data);
+ } catch (e) {
+ console.log("Oh no an error!", e);
+ }
+}
+
+sayHi();
+```
+
+- A: `"It worked! Hello world!"`
+- B: `"Oh no an error: undefined`
+- C: `SyntaxError: can only throw Error objects`
+- D: `"Oh no an error: Hello world!`
+
+答え
+
+
+#### 答え: D
+
+`throw`ステートメントを使って、カスタムエラーを作ることができます。このステートメントで、あなたは例外を投げることができます。例外は、string, number, boolean, objectのいずれかとなります。上記の場合だと、例外は文字列`'Hello world'`となります。
+
+`catch`ステートメントを使って、`try`ブロックで例外が投げられた場合にどうするかを指定できます。例外がスローされます: 文字列`'Hello world'`は、`e`に代入されます。その結果`'Oh an error: Hello world'`となります。
+
+
+
+
+---
+
+###### 53. 何が出力されるでしょうか?
+
+```javascript
+function Car() {
+ this.make = "Lamborghini";
+ return { make: "Maserati" };
+}
+
+const myCar = new Car();
+console.log(myCar.make);
+```
+
+- A: `"Lamborghini"`
+- B: `"Maserati"`
+- C: `ReferenceError`
+- D: `TypeError`
+
+答え
+
+
+#### 答え: B
+
+プロパティを返すと、そのプロパティの値は、コンストラクタ関数で設定された値ではなく、"戻り値"となります。 `"Maserati"`という文字列を返すので、`myCar.make`は `"Maserati"`となります。
+
+
+
+
+---
+
+###### 54. 何が出力されるでしょうか?
+
+```javascript
+(() => {
+ let x = (y = 10);
+})();
+
+console.log(typeof x);
+console.log(typeof y);
+```
+
+- A: `"undefined", "number"`
+- B: `"number", "number"`
+- C: `"object", "number"`
+- D: `"number", "undefined"`
+
+答え
+
+
+#### 答え: A
+
+`let x = y = 10;` is actually shorthand for:
+
+```javascript
+y = 10;
+let x = y;
+```
+
+`y`に`10`を代入すると、実際にはグローバルオブジェクトにプロパティ`y`が追加されます(ブラウザでは`window`、nodeでは`global`)。ブラウザでは、`window.y`は`10`となりました。
+
+それから、変数`x`を`10`である値`y`で宣言します。`let`キーワードで宣言された変数は"ブロックスコープ"となり、宣言されたブロック内でのみ定義されます。この場合は即時関数(IIFE)となります。
+
+`typeof`演算子使用時、オペランド`x`は定義されていません: 宣言されているブロックの外側で`x`にアクセスしようとしています。これは`x`が定義されていないことを意味します。
+
+値が割り当てられていない、または宣言されていない値は`"undefined"`型となります。なので`console.log(typeof x)`は`"undefined"`を返します。
+
+yに関しては、`y`に`10`を代入するときにグローバル変数`y`を作成しました。この値は、コード内のどこからでもアクセスできます。`y`が定義されていて、`"number"`型の値を保持します。よって`console.log(typeof y)`は`"number"`を返します。
+
+
+
From 161a4ab207c119e52c5fa75f8baedbb62799b31b Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Mon, 24 Jun 2019 18:43:34 +0200
Subject: [PATCH 080/881] Translate in french answer 16 to 23
---
README_fr-FR.md | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 0eb2fb44..d6d2a595 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -465,9 +465,9 @@ sum(1, "2");
#### Réponse: C
-JavaScript is a **dynamically typed language**: we don't specify what types certain variables are. Values can automatically be converted into another type without you knowing, which is called _implicit type coercion_. **Coercion** is converting from one type into another.
+JavaScript est un **langage à types dynamiques** : nous n'avons pas besoin de spécifier le types des variables. Les valeurs peuvent être automatiquement convertir vers les autres types sans que vous le sachiez, c'est ce que l'on appelle _la conversion de types implicites_ _(implicit type coercion)_.
-In this example, JavaScript converts the number `1` into a string, in order for the function to make sense and return a value. During the addition of a numeric type (`1`) and a string type (`'2'`), the number is treated as a string. We can concatenate strings like `"Hello" + "World"`, so what's happening here is `"1" + "2"` which returns `"12"`.
+Dans cette exemple, JavaScript convertit le nombre `1` en un chaine de caractère, afin que la fonction est du sens et puisse renvoyer un valeur. Durant l'addition d'un type numérique (`1`) et d'un type chaine de caractère (`'2'`), le nombre est traité comme une chaine de caractère. Nous pouvons concaténer les chaines de caractères comme `"Hello" + "World"`, c'est donc ce qui arrive ici avec `"1" + "2"` qui retourne `"12"`.
@@ -493,17 +493,17 @@ console.log(number);
#### Réponse: C
-The **postfix** unary operator `++`:
+L'opérateur arithmétique **postfix** `++` :
-1. Returns the value (this returns `0`)
-2. Increments the value (number is now `1`)
+1. Retourne la valeur (ici il retourne `0`)
+2. Incrémente la valeur (le nombre est maintenant égal à `1`)
-The **prefix** unary operator `++`:
+L'opérateur arithmétique **préfix** `++` :
-1. Increments the value (number is now `2`)
-2. Returns the value (this returns `2`)
+1. Incrémente la valeur (le nombre est maintenant égal à `2`)
+2. Retourne la valeur (ici il retourne `2`)
-This returns `0 2 2`.
+Cela retourne donc `0 2 2`.
@@ -534,7 +534,7 @@ getPersonInfo`${person} is ${age} years old`;
#### Réponse: B
-If you use tagged template literals, the value of the first argument is always an array of the string values. The remaining arguments get the values of the passed expressions!
+Si vous utilisez les template de chaine de caractère, la valeur du premier argument sera toujours un tableau de valeurs des chaines de caractère. Le reste des arguments seront les valeurs des expressions utilisées !
@@ -566,11 +566,11 @@ checkAge({ age: 18 });
#### Réponse: C
-When testing equality, primitives are compared by their _value_, while objects are compared by their _reference_. JavaScript checks if the objects have a reference to the same location in memory.
+Lorsque l'on teste une égalité, les primitifs sont comparés par leur valeur, alors que les objet sont comparés par leur _référence_. JavaScript vérifie si les objets ont une référence à la même zone de la mémoire.=
-The two objects that we are comparing don't have that: the object we passed as a parameter refers to a different location in memory than the object we used in order to check equality.
+Les 2 objets que nous comparons n'ont pas ça : l'objet passé en paramètre fait référence à une zone mémoire différente que l'objet que nous utilisons pour faire la comparaison.
-This is why both `{ age: 18 } === { age: 18 }` and `{ age: 18 } == { age: 18 }` return `false`.
+C'est pourquoi l;es 2 conditions `{ ag: 18 } === { age: 18 }` et `{ age: 18 } == { age: 18 }` retournent `false`.
@@ -597,7 +597,7 @@ getAge(21);
#### Réponse: C
-The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
+L'opérateur de destructuration _(spread operator)_ (`...args`) retourne un tableau avec les arguments. Un tableau est un objet, donc `typeof args` retournera `"object"`.
@@ -626,7 +626,7 @@ getAge();
#### Réponse: C
-With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. If we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
+Avec `"use strict"`, vous pouvez êtes sûr de ne pas déclarer accidentellement des variables gloables. Nous ne déclarerons jamais la variable `age`, et temps que nous utiliserons `"use strict"`, cela créera une erreur de référence. Si nous n'utilisons pas `"use strict"`, cela fonctionnera et la variable `age` sont attribué à l'objet global.
@@ -649,7 +649,7 @@ const sum = eval("10*10+5");
#### Réponse: A
-`eval` evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is `10 * 10 + 5`. This returns the number `105`.
+`eval` évalue les codes que nous passons en paramétre de type chaine de caractères. Si c'est une expression, comme dans notre cas, il évaluera l'expression. L'expression est `10 * 10 + 5`, ce qui retourne le nombre `105`.
@@ -672,9 +672,9 @@ sessionStorage.setItem("cool_secret", 123);
#### Réponse: B
-The data stored in `sessionStorage` is removed after closing the _tab_.
+La donnée stocké dans le `sessionStorage` est supprimée après la fermeture de l'onglet.
-If you used `localStorage`, the data would've been there forever, unless for example `localStorage.clear()` is invoked.
+Si vous utilisez le `localStorage`, la donnée sera là pour toujours, jusqu'à ce que, par exemple, `localStorage.clear()` soit invoquée.
@@ -700,9 +700,9 @@ console.log(num);
#### Réponse: B
-With the `var` keyword, you can declare multiple variables with the same name. The variable will then hold the latest value.
+Avec le mot clé `var`, vous pouvez déclarer plusieurs variables avec le même nom. La variable aura pour valeur la dernière assignée.
-You cannot do this with `let` or `const` since they're block-scoped.
+Vous ne pouvez par faire cela avec `let` ou `const` puisqu'ils ont une portée de bloc.
From 9b31ffe2a636acfa690557a0324d291a7d344b6b Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Mon, 24 Jun 2019 20:38:29 +0200
Subject: [PATCH 081/881] Translate in FR answers 24 to 43
---
README_fr-FR.md | 86 ++++++++++++++++++++++++-------------------------
1 file changed, 43 insertions(+), 43 deletions(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index d6d2a595..a8dfb5c1 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -731,9 +731,9 @@ set.has(1);
#### Réponse: C
-All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
+Toutes les clés d'objet (à l'exception des symboles) sont des chaînes de caratères sous le capot, même si vous ne les tapez pas vous-même en tant que chaîne. C'est pourquoi `obj.hasOwnProperty('1')` renvoie également la valeur `true`.
-It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')` returns `false`. It has the numeric type `1`, `set.has(1)` returns `true`.
+Ça ne marche pas comme ça pour un set. Il n'y a pas de `'1'` dans notre ensemble : `set.has('1')` renvoie `false`. Il a le type numérique `1`, `set.has(1)` renvoie `true`.
@@ -757,7 +757,7 @@ console.log(obj);
#### Réponse: C
-If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
+Si vous avez deux clés portant le même nom, la clé sera remplacée. Elle sera toujours dans sa première position, mais avec la dernière valeur spécifiée.
@@ -775,7 +775,7 @@ If you have two keys with the same name, the key will be replaced. It will still
#### Réponse: A
-The base execution context is the global execution context: it's what's accessible everywhere in your code.
+Le contexte d'exécution de base est le contexte d'exécution global: c'est ce qui est accessible partout dans votre code.
@@ -801,7 +801,7 @@ for (let i = 1; i < 5; i++) {
#### Réponse: C
-The `continue` statement skips an iteration if a certain condition returns `true`.
+L'instruction `continue` ignore une itération si une condition donnée renvoie `true`.
@@ -830,7 +830,7 @@ name.giveLydiaPizza();
#### Réponse: A
-`String` is a built-in constructor, which we can add properties to. I just added a method to its prototype. Primitive strings are automatically converted into a string object, generated by the string prototype function. So, all strings (string objects) have access to that method!
+`String` est un constructeur intégré, auquel nous pouvons ajouter des propriétés. Je viens d'ajouter une méthode à son prototype. Les chaînes de caratère primitives sont automatiquement converties en un objet chaîne, généré par la fonction prototype de chaîne. Ainsi, toutes les chaînes (objets de chaîne) ont accès à cette méthode !
@@ -860,11 +860,11 @@ console.log(a[b]);
#### Réponse: B
-Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`.
+Les clés d'objet sont automatiquement converties en chaînes de caractère. Nous essayons de définir un objet en tant que clé de l'objet `a`, avec la valeur `123`.
-However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
+Cependant, lorsque nous transformons un objet en chaine de caractère, il devient `"[Objet objet]"`. Donc, ce que nous disons ici, c'est que un `a["Objet objet"] = 123`. Ensuite, nous pouvons essayer de refaire la même chose. `c` est un autre objet que nous sommes implicitement en train de transformer en chaine de carctère. Donc, `a["Objet objet"] = 456`.
-Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to `456`, so it returns `456`.
+Ensuite, nous affichons `a[b]`, qui est en fait `a["Objet objet"]`. Que nous venons de définir à `456`, nous renvoyons donc `456`.
@@ -893,31 +893,31 @@ baz();
#### Réponse: B
-We have a `setTimeout` function and invoked it first. Yet, it was logged last.
+Nous avons une fonction `setTimeout` et nous l'avons d'abord appelée. Pourtant, il a été affiché en dernier.
-This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
+En effet, dans les navigateurs, nous n’avons pas seulement le moteur d’exécution, nous avons aussi quelque chose appelé `WebAPI`. `WebAPI` nous donne la fonction` setTimeout` pour commencer, et par exemple le DOM.
-After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
+Une fois que la fonction de rappel _(callback)_ est poussée via la WebAPI, la fonction `setTimeout` elle-même (mais pas la fonction de rappel !) est extraite de la pile.
-Now, `foo` gets invoked, and `"First"` is being logged.
+Maintenant, `foo` est invoqué et `"Premier"` est affiché.
-`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged.
+`foo` est extrait de la pile et `baz` est invoqué. `"Troisième"` est affiché.
-The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_.
+WebAPI ne peut simplement pas ajouter des éléments à la pile dès qu’elle est prête. Au lieu de cela, elle pousse la fonction de rappel vers quelque chose appelé la _file d'attente_.
-This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
+C'est ici qu'une boucle d'événement commence à fonctionner. La **boucle d'événement** examine la pile et la file d'attente des tâches. Si la pile est vide, il prend la première chose dans la file d'attente et la pousse sur la pile.
-`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack.
+`bar` est invoqué, `"Second"` est affiché et il est sorti de la pile.
@@ -946,7 +946,7 @@ This is where an event loop starts to work. An **event loop** looks at the stack
#### Réponse: C
-The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+L'élément imbriqué le plus profond qui a provoqué l'événement est la cible de l'événement. Vous pouvez arrêter le bouillonnement _(bubbling)_ en utilisant `event.stopPropagation`.
@@ -973,7 +973,7 @@ The deepest nested element that caused the event is the target of the event. You
#### Réponse: A
-If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
+Si nous cliquons sur `p`, nous verrons deux lignes : `p` et `div`. Lors de la propagation d'un événement, il y a 3 phases: capture, cible et bouillonnement _(bubbling)_. Par défaut, les gestionnaires d'événements sont exécutés dans la phase de bouillonnement (sauf si vous définissez `useCapture` sur` true`). Il va de l'élément imbriqué le plus profond vers l'extérieur.
@@ -1003,9 +1003,9 @@ sayHi.bind(person, 21);
#### Réponse: D
-With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
+Avec les deux, nous pouvons transmettre l'objet auquel nous voulons que le mot clé `this` fasse référence. Cependant, `.call` est aussi _exécuté immédiatement_ !
-`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
+`.bind.` renvoie une copie de la fonction, mais avec un contexte lié ! Elle n'est pas exécuté immédiatement.
@@ -1032,9 +1032,9 @@ typeof sayHi();
#### Réponse: B
-The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+La fonction `sayHi` renvoie la valeur renvoyée par la fonction immédiatement appelée (IIFE). Cette fonction a renvoyé `0`, qui est du type `"nombre"`.
-FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+Pour info : il n'y a que 7 types natifs : `null`, `undefined`, `boolean`, `number`, `string`, `object` et `symbol`. `"function"` n'est pas un type, puisque les fonctions sont des objets, il est de type `"object"`.
@@ -1062,16 +1062,16 @@ undefined;
#### Réponse: A
-There are only six falsy values:
+Il n'y a que six valeurs de fausses :
- `undefined`
- `null`
- `NaN`
- `0`
-- `''` (empty string)
+- `''` (chaine de caractère vide)
- `false`
-Function constructors, like `new Number` and `new Boolean` are truthy.
+Les constructeurs de fonctions, comme `new Number` et `new Boolean` sont la vraies.
@@ -1094,8 +1094,8 @@ console.log(typeof typeof 1);
#### Réponse: B
-`typeof 1` returns `"number"`.
-`typeof "number"` returns `"string"`
+`typeof 1` retourne `"number"`.
+`typeof "number"` retourne `"string"`
@@ -1120,11 +1120,11 @@ console.log(numbers);
#### Réponse: C
-When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like:
+Lorsque vous définissez une valeur sur un élément d'un tableau qui dépasse la longueur du tableau, JavaScript crée un quelque chose appelé "emplacements vides". Ceux-ci ont en fait la valeur `undefined`, mais vous verrez quelque chose comme :
`[1, 2, 3, 7 x empty, 11]`
-depending on where you run it (it's different for every browser, node, etc.)
+en fonction de l'endroit où vous l'exécutez (différent pour chaque navigateur, nœud, etc.).
@@ -1157,11 +1157,11 @@ depending on where you run it (it's different for every browser, node, etc.)
#### Réponse: A
-The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
+Le bloc `catch` reçoit l'argument `x`. Ce n'est pas le même `x` que la variable que nous passons en arguments. Cette variable `x` a une portée de bloc.
-Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+Plus tard, nous définissons cette variable de bloc égale à `1` et définissons la valeur de la variable `y`. Maintenant, nous affichons la variable `x` de portée de bloc, dont la valeur est égale à `1`.
-Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+En dehors du bloc `catch`, `x` est toujours `undefined` et `y` est égal à `2`. Lorsque nous voulons `console.log(x)` en dehors du bloc `catch`, il renvoie `undefined`, et `y` renvoie `2`.
@@ -1180,11 +1180,11 @@ Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we
#### Réponse: A
-JavaScript only has primitive types and objects.
+JavaScript n'a que des types et des objets primitifs.
-Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+Les types primitifs sont `boolean`, `null`, `undefined`, `bigint`, `number`, `string` et `symbol`.
-What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+Ce qui différencie une primitive d'un objet, c'est que les primitives n'ont aucune propriété ou méthode. Cependant, vous remarquerez que `'foo'.toUpperCase()` est évalué à `'FOO'` et n'entraîne pas de `TypeError`. En effet, lorsque vous essayez d'accéder à une propriété ou à une méthode sur une primitive telle qu'une chaîne, JavaScript encapsule implicitement l'objet à l'aide de l'une des classes d'encapsuleur, à savoir `String`, puis supprime immédiatement l'encapsuleur après l'évaluation de l'expression. Toutes les primitives à l'exception de `null` et` undefined` présentent ce comportement.
@@ -1212,9 +1212,9 @@ What differentiates a primitive from an object is that primitives do not have an
#### Réponse: C
-`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
+`[1, 2]` est notre valeur initiale. C'est la valeur avec laquelle nous commençons et la valeur du tout premier `acc`. Au premier tour, `acc` est `[1,2]` et `cur` est `[0, 1]`. Nous les concaténons, ce qui donne `[1, 2, 0, 1]`.
-Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
+Ensuite, `acc` est `[1, 2, 0, 1]` et `cur` est `[2, 3]`. Nous les concaténons et obtenons `[1, 2, 0, 1, 2, 3]`
@@ -1239,11 +1239,11 @@ Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and ge
#### Réponse: B
-`null` is falsy. `!null` returns `true`. `!true` returns `false`.
+`null` est faux. `!null` retourne `true`. `!true` retourne `false`.
-`""` is falsy. `!""` returns `true`. `!true` returns `false`.
+`""` est faux. `!""` retourne `true`. `!true` retourne `false`.
-`1` is truthy. `!1` returns `false`. `!false` returns `true`.
+`1` est vrai. `!1` retourne `false`. `!false` retourne `true`.
@@ -1266,7 +1266,7 @@ setInterval(() => console.log("Hi"), 1000);
#### Réponse: A
-It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function.
+Il retourne un identifiant unique. Cet identifiant peut être utilisé pour effacer cet interval avec la fonction `clearInterval()`.
@@ -1289,7 +1289,7 @@ It returns a unique id. This id can be used to clear that interval with the `cle
#### Réponse: A
-A string is an iterable. The spread operator maps every character of an iterable to one element.
+Une chaîne de caractère est itérable. L'opérateur de desconstruction transforme chaque caractère d'un itérable en un élément.
From 1cacef1569f5fc7bbc3c025f96189b759df65c64 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Mon, 24 Jun 2019 21:44:52 +0200
Subject: [PATCH 082/881] 4 - 7 Arabic translation
Added Translation for question 4 - 5 - 6 - 7.
---
README_AR.md | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 128 insertions(+)
diff --git a/README_AR.md b/README_AR.md
index 43351549..7ee5f70b 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -121,6 +121,134 @@ shape.perimeter();
لا توجد قيمة `radius` في ذلك ال object لهذا يقوم بإرجاع القيمة `undefined`.
+
+
+
+---
+
+4. ماهو الناتج؟
+
+```javascript
++true;
+!"Lydia";
+```
+
+- A: `1` and `false`
+- B: `false` and `NaN`
+- C: `false` and `false`
+
+
الإجابة
+
+
+الجواب هو الخيار الأول : A
+
+عملية الزيادة الأحادية هنا وجدت لكي تقوم بتحويل المعامل الى رقم, `true` هي `1` , و `false` هي `0`.
+ المتغير من نوع string `'Lydia'` هو قيمة صدقية أو حقيقية, بمعنى أنها تساوي `true` . السؤال الذي نقوم بطرحه هنا, هو هل هذه القيمة الصدقية هي قيمة غير صدقية؟ اي تساوي `false`؟ لهذا نتحصل على الجواب `false`.
+
+
+
+---
+
+5. أي الإجابات هو إجابة صحيحة؟
+
+```javascript
+const bird = {
+ size: "small"
+};
+
+const mouse = {
+ name: "Mickey",
+ small: true
+};
+```
+
+- A: `mouse.bird.size` غير صحيحة
+- B: `mouse[bird.size]` غير صحيحة
+- C: `mouse[bird["size"]]` غير صحيحة
+- D: كل الإجابات صحيحة
+
+الإجابة
+
+
+الجواب هو الخيار الأول: A
+
+في لغة الجافا سكريبت, جميع مفاتيح الobjects هي من النوع string. الا اذا كانت عبارة عن symbol. حتى ولو أننا في بعض المرات لانقوم بوضع نوعها على انها string بصورة صريحة, ولكنها دائما يتم تحويلها الى نوع string وراء الكواليس.
+
+لغة الجافاسكريبت تقوم بترجمةال statements.عندما نقوم باستعمال ال bracket notation, تقوم الجافا سكريبت اولا برؤية أول فتحة للقوس `[` و تقوم بالمتابعة الى ان تجد قفلة هذا القوس `]`.فقط عندما تصل الى قفلة القوس حتى تقوم بتقييم ال statement و من ثم معالجتها.
+`mouse[bird.size]`: اولا تقوم بتقييم`bird.size`, والتي هي تساوي `"small"`. `mouse["small"]` تقوم بإرجاع`true`
+
+ولكن في المقابل, عندما نقوم بإستخدام ال dot notation,لا يتم معالجة الأمر هكذا. `mouse` ليس لديها مفتاح يسمى `bird`, و هذا يعني أن `mouse.bird` هي قيمة `undefined`. بالتالي نقوم بالسؤال عن ال`size` بإستخدام ال dot notation: للسؤال عن قيمة `mouse.bird.size`.
+وبما أن `mouse.bird`قيمتها `undefined` ف نحن فعليا نقوم بالسؤال عن `undefined.size` و التي هي بالتأكيد غير صحيحة و غير صالحة و ستقوم بإرجاع error مشابه ل `Cannot read property "size" of undefined`.
+
+
+
+---
+
+6. ماهو الناتج؟
+
+```javascript
+let c = { greeting: "Hey!" };
+let d;
+
+d = c;
+c.greeting = "Hello";
+console.log(d.greeting);
+```
+
+- A: `Hello`
+- B: `Hey`
+- C: `undefined`
+- D: `ReferenceError`
+- E: `TypeError`
+
+الإجابة
+
+
+الجواب هو الخيار الأول : A
+
+في لغة الجافاسكريبت, جميع ال objectsيتم التفاعل معها عن طريق _reference_ و ذلك عندما نقوم بمساواتهم ببعضهم البعض بعلامة ال=.
+
+أولا, المتغير `c` يحمل قيمة ل object. لاحقا قمنا بإضافة `d` لنفس الrefence الذي لدى المتغير `c` لل object.
+
+

+
+لذا, عندما تقوم بتغيير object واحد , انت فعليا تقوم بتغيير جميع الobjects.
+
+
+
+
+---
+
+7. ماهو الناتج؟
+
+```javascript
+let a = 3;
+let b = new Number(3);
+let c = 3;
+
+console.log(a == b);
+console.log(a === b);
+console.log(b === c);
+```
+
+- A: `true` `false` `true`
+- B: `false` `false` `true`
+- C: `true` `false` `false`
+- D: `false` `true` `true`
+
+الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+`new Number()` هي دالة من نوع built-in function constructer. على الرغم من أنها تبدو كرقم, ولكنها في الحقيقة ليس رقم, هي عبارة عن object ولديها العديد العديد من المميزات.
+
+عندما نقوم بإستخدام العلامة او العامل `==`, هي تقوم فقط بالتحقق من إذا ماكان لديها same _value_.كلا الطرفين قيمتهم تساوي `3` لهذا تقوم بإرجاع `true`.
+
+و لكن على الرغم من هذا, عندما نقوم بإستخدام العملية أو المعامل `===`, كلا القيمة _and_ النوع يجب ان يكونا نفس الشيء.
+
+هي ليست `new Number()` هي ليست عبارة عن رقم, هي عبارة عن **object** , وكلاهما سيقومان بإرجاع `false.`
+
From 2f6139a85efbf960068ac55844c13a660ef9203a Mon Sep 17 00:00:00 2001
From: Ihor Sychevskyi <26163841+Arhell@users.noreply.github.com>
Date: Tue, 25 Jun 2019 01:02:43 +0300
Subject: [PATCH 083/881] Updated syntax highlighting in first response. UA
---
README-ua_UA.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README-ua_UA.md b/README-ua_UA.md
index c14d922e..54eb1f99 100644
--- a/README-ua_UA.md
+++ b/README-ua_UA.md
@@ -38,7 +38,7 @@ sayHi();
#### Відповідь: D
-Усередині функції ми спершу визначаємо змінну `name` за допомогою ключового слова `var`. Це означає, що змінна буде знайдена (область пам'яті під змінну буде виділена під час створення) зі значенням `undefined` за замовчуванням, до тих пір поки виконання коду не дійде до рядка, де визначається змінна. Ми ще не визначили значення name, коли намагаємося вивести її в консоль, тому в консолі буде `undefined`.
+Усередині функції ми спершу визначаємо змінну `name` за допомогою ключового слова `var`. Це означає, що змінна буде знайдена (область пам'яті під змінну буде виділена під час створення) зі значенням `undefined` за замовчуванням, до тих пір поки виконання коду не дійде до рядка, де визначається змінна. Ми ще не визначили значення `name`, коли намагаємося вивести її в консоль, тому в консолі буде `undefined`.
Змінні, визначені за допомогою `let` (і `const`), також знаходяться, але на відміну від `var`, не створюються. Доступ до них неможливий до тих пір, поки не виконається рядок їх визначення (ініціалізації). Це називається "тимчасова мертва зона". Коли ми намагаємося звернутися до змінних до того моменту як вони визначені, JavaScript видає `ReferenceError`.
From eeefec8909889aed31a7488676320a00160acb40 Mon Sep 17 00:00:00 2001
From: Josselin Buils
Date: Tue, 25 Jun 2019 11:54:28 +0200
Subject: [PATCH 084/881] Fixes answer of question 52 and adds missing quotes
---
README-de_DE.md | 4 ++--
README.md | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/README-de_DE.md b/README-de_DE.md
index 706654cb..51456884 100644
--- a/README-de_DE.md
+++ b/README-de_DE.md
@@ -1570,9 +1570,9 @@ sayHi();
```
- A: `"It worked! Hello world!"`
-- B: `"Oh no an error: undefined`
+- B: `"Oh no an error: undefined"`
- C: `SyntaxError: can only throw Error objects`
-- D: `"Oh no an error: Hello world!`
+- D: `"Oh no an error! Hello world!"`
Antwort
diff --git a/README.md b/README.md
index 52c948f6..5c9fb4b9 100644
--- a/README.md
+++ b/README.md
@@ -1572,9 +1572,9 @@ sayHi();
```
- A: `"It worked! Hello world!"`
-- B: `"Oh no an error: undefined`
+- B: `"Oh no an error: undefined"`
- C: `SyntaxError: can only throw Error objects`
-- D: `"Oh no an error: Hello world!`
+- D: `"Oh no an error! Hello world!"`
Answer
From ecbc6a7009de3daf7597f385e3b238954cb0836c Mon Sep 17 00:00:00 2001
From: kimdanah
Date: Wed, 26 Jun 2019 00:54:08 +0900
Subject: [PATCH 085/881] Translate the questions 21-30 to Korean
---
README-ko_KR.md | 65 ++++++++++++++++++++++++++-----------------------
1 file changed, 34 insertions(+), 31 deletions(-)
diff --git a/README-ko_KR.md b/README-ko_KR.md
index 13154c27..5df54822 100644
--- a/README-ko_KR.md
+++ b/README-ko_KR.md
@@ -163,7 +163,7 @@ const mouse = {
#### 정답: A
-JavaScript에서, 모든 객체 키는 문자열이에요 (Symbol이 아닌 한). 비록 그것을 문자열 _타입_ 으로 입력하지 않아도, 항상 밑바닥에서 문자열로 변환되요.
+JavaScript에서, 모든 객체 키는 문자열이에요 (Symbol이 아닌 한). 비록 그것을 문자열 _타입_ 으로 입력하지 않아도, 항상 내부적으로 문자열로 변환되요.
JavaScript는 문장을 해석(또는 박스해제)해요. 대괄호 표기를 사용하면, 첫 번째 좌대괄호 `[`를 보고 오른쪽 대괄호 `]`를 찾을 때까지 진행해요. 그때, 그 문장을 평가할거에요.
@@ -298,7 +298,7 @@ console.log(greetign);
#### 정답: A
-객체는 출력되요, 전역객체에 빈 객체를 방금 만들었기 때문이에요. `greeting`을 `greettign`으로 잘못 입력했을 경우, JS 터프리터는 실제로 이것을 `global.greettign = {}` (또는 브라우저의 `window.greetign = {}`) 라고 간주해요.
+객체는 출력되요, 전역객체에 빈 객체를 방금 만들었기 때문이에요. `greeting`을 `greettign`으로 잘못 입력했을 경우, JS 인터프리터는 실제로 이것을 `global.greettign = {}` (또는 브라우저의 `window.greetign = {}`) 라고 간주해요.
이것을 피하기 위해서, `"use strict"`를 사용할 수 있어요. 이렇게 하면 변수를 어떤 것과 동일하게 설정하기 전에 변수를 선언했는지 확인할 수 있어요.
@@ -328,7 +328,7 @@ bark.animal = "dog";
#### 정답: A
JavaScript에서는 가능해요, 함수는 객체이기 때문이에요!
-(프리미티브형 이외는 모두 객체)
+(윈시형 이외는 모두 객체)
함수는 특별한 종류의 객체에요. 당신이 쓴 코드는 실제 함수가 아니에요. 함수는 속성을 가진 객체에요. 이 속성은 호출이 가능해요.
@@ -571,7 +571,7 @@ checkAge({ age: 18 });
#### 정답: C
-동등성을 테스트할 때, 프리미티브는 그 _값_ 에 따라 비교되며, 객체는 그들의 _참조_ 에 따라 비교되요. JavaScript 객체가 메모리내의 같은 장소를 참조하고 있는지 여부를 확인해요.
+동등성을 테스트할 때, 원시형은 그 _값_ 에 따라 비교되며, 객체는 그들의 _참조_ 에 따라 비교되요. JavaScript 객체가 메모리내의 같은 장소를 참조하고 있는지 여부를 확인해요.
비교하고 있는 두개의 객체는 그것이 없어요: 파라미터로 전달된 객체와 동등성을 확인하기 위해 사용한 객체는 메모리 내의 다른 장소를 참조해요.
@@ -654,32 +654,32 @@ const sum = eval("10*10+5");
#### 정답: A
-`eval` evaluates codes that's passed as a string. If it's an expression, like in this case, it evaluates the expression. The expression is `10 * 10 + 5`. This returns the number `105`.
+`eval` 문자열로서 통과된 코드를 평가해요. 이 경우와 같이 만약 그것이 표현식이라면, 표현식을 평가해요. 표현식은 `10 * 10 + 5` 이에요. 이것은 숫자 `105`를 리턴해요.
---
-###### 22. How long is cool_secret accessible?
+###### 22. cool_secret에 몇시간 접근이 가능 할까요 ?
```javascript
sessionStorage.setItem("cool_secret", 123);
```
-- A: Forever, the data doesn't get lost.
-- B: When the user closes the tab.
-- C: When the user closes the entire browser, not only the tab.
-- D: When the user shuts off their computer.
+- A: 영원히, 데이터는 사라지지 않아요.
+- B: 사용자가 탭을 닫을 때.
+- C: 사용자가 탭 뿐만 아니라, 브라우저 전체를 닫을 때.
+- D: 사용자가 자신의 컴퓨터를 종료시켰을때.
정답
#### 정답: B
-The data stored in `sessionStorage` is removed after closing the _tab_.
+`sessionStorage`에 저장된 데이터는 _탭_ 을 닫은 후에 삭제되요.
-If you used `localStorage`, the data would've been there forever, unless for example `localStorage.clear()` is invoked.
+만약 `localStorage`를 사용했다면, 예를들어 `localStorage.clear()`를 호출 하지 않는 한, 데이터는 영원할거에요.
@@ -705,9 +705,9 @@ console.log(num);
#### 정답: B
-With the `var` keyword, you can declare multiple variables with the same name. The variable will then hold the latest value.
+`var`키워드를 사용하면, 같은 이름으로 복수의 변수를 선언 할 수 있어요. 변수는 최신의 값을 유지해요.
-You cannot do this with `let` or `const` since they're block-scoped.
+블록 스코프의 `let` 또는 `const`에서는 할 수 없어요.
@@ -736,9 +736,10 @@ set.has(1);
#### 정답: C
-All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
+모든 객체 키(Symbols 제외)
+모든 객체 키는(Symbol 제외) 문자열로 직접 입력하지 않아도, 내부적으로는 문자열이에요. 이것이 `obj.hasOwnProperty('1')` 또한 true를 리턴하는 이유에요.
-It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')` returns `false`. It has the numeric type `1`, `set.has(1)` returns `true`.
+set에서는 작동하지 않아요. set에는 `'1'`이 없어요: `set.has('1')`는 `false`를 리턴해요. 그것은 수형인 `1`을 가지고 있어, `set.has(1)`은 `true`를 리턴해요.
@@ -762,14 +763,14 @@ console.log(obj);
#### 정답: C
-If you have two keys with the same name, the key will be replaced. It will still be in its first position, but with the last specified value.
+같은 이름의 키를 두개 가지고 있다면, 첫번째 위치에서, 마지막에 지정된 값으로 대체 될 거에요.
---
-###### 26. The JavaScript global execution context creates two things for you: the global object, and the "this" keyword.
+###### 26. JavaScript의 global execution context는 두개를 작성해요. : 전역객체와 "this" 키워드에요.
- A: true
- B: false
@@ -780,7 +781,7 @@ If you have two keys with the same name, the key will be replaced. It will still
#### 정답: A
-The base execution context is the global execution context: it's what's accessible everywhere in your code.
+기본적인 execution context는 전역 실행 문장이에요: 당신의 코드 모든 곳에서 접근 할 수 있어요.
@@ -806,7 +807,7 @@ for (let i = 1; i < 5; i++) {
#### 정답: C
-The `continue` statement skips an iteration if a certain condition returns `true`.
+`continue` 표현식은 특정 조건이 `true`를 리턴하면 반복처리를 건너뛰어요.
@@ -835,7 +836,7 @@ name.giveLydiaPizza();
#### 정답: A
-`String` is a built-in constructor, which we can add properties to. I just added a method to its prototype. Primitive strings are automatically converted into a string object, generated by the string prototype function. So, all strings (string objects) have access to that method!
+`String`은 내장 생성자로 속성을 추가 할 수 있어요. 단지 프로토타입이라는 메소드를 추가했어요. 원시형 문자열은 문자열 프로토타입 함수에 의해 생성된 문자열 객체로 자동 변환되요. 그래서, 모든 문자열(문자열 객체)는 그 메소드에 접근 할 수 있어요!
@@ -865,11 +866,11 @@ console.log(a[b]);
#### 정답: B
-Object keys are automatically converted into strings. We are trying to set an object as a key to object `a`, with the value of `123`.
+객체 키는 자동으로 문자열로 변환되요. 객체 `a`의 키 값으로 `123`를 세팅하려고 해요.
-However, when we stringify an object, it becomes `"[Object object]"`. So what we are saying here, is that `a["Object object"] = 123`. Then, we can try to do the same again. `c` is another object that we are implicitly stringifying. So then, `a["Object object"] = 456`.
+그러나, 객체를 문자열화 하면 `"[Object object]"`가 되요. 그래서 여기서 밀하고자 하는 건 `a["Object object"] = 123` 이라는 거에요. 그후, 같은 일을 다시 시도해요. `c`는 암묵적으로 문자열화 한 다른객체에요. 그래서 `a["Object object"] = 456`이 되요.
-Then, we log `a[b]`, which is actually `a["Object object"]`. We just set that to `456`, so it returns `456`.
+그후, `a[b]`는 출력하면 실제로는 `a["Object object"]`에요. 단지 `456`를 설정 했기때문에, `456`를 리턴해요.
@@ -898,31 +899,33 @@ baz();
#### 정답: B
-We have a `setTimeout` function and invoked it first. Yet, it was logged last.
+`setTimeout`함수를 처음으로 호출 했어요. 그러나 그것은 마지막에 출력되요.
-This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
+브라우저에는 런타임 엔진 뿐만 아니라 `WebAPI`라고 불리는 것도 있기 때문이에요. `WebAPI`는 `setTimeout`함수를 최초에 부여하는데, DOM을 예로 들 수 있어요.
After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
+_callback_ 이 WebAPI에 푸시된 후, `setTimeout`함수 자체(callback이 아니에요!)는 stack에 사라졌어요.
+

-Now, `foo` gets invoked, and `"First"` is being logged.
+지금, `foo` 는 호출 되었고, `"First"`는 출력 되었어요.

-`foo` is popped off the stack, and `baz` gets invoked. `"Third"` gets logged.
+`foo`는 stack에 사라지고, `baz`가 호출 되었어요. `"Third"`가 출력 되었어요.

-The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pushes the callback function to something called the _queue_.
+WebAPI는 준비가 될때 마다 stack에 항목을 추가 할 수 없어요. 대신에, _queue_ 라고 불리는 것에 callback함수를 푸시해요.

-This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
+여기서 event loop가 작동하기 시작해요. **event loop**는 stack과 task queue를 봐요. stack이 비어있다면, queue에 첫번째것을 가져다가 stack 위로 푸시해요.

-`bar` gets invoked, `"Second"` gets logged, and it's popped off the stack.
+`bar`가 호출되었고, `"Second"`가 출력 되었으며, stack에서 사라졌어요.
From 7a252c180da3d68889ec2cc4fcc059d509b1ac5b Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Wed, 26 Jun 2019 00:04:47 +0200
Subject: [PATCH 086/881] Questions 8 to 20 added (Arabic Translation)
---
README_AR.md | 403 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 403 insertions(+)
diff --git a/README_AR.md b/README_AR.md
index 7ee5f70b..8499b16e 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -11,6 +11,8 @@
الأجوبة توجد في الجزء المطوي بالأسفل أدناه تحت كل سؤال على حدة, فقط قم بالضغط على كلمة الإجابة لكي تحصل على الإجابة, حظا موفقا :heart:
+اللغات المتوفرة:
+
[English](https://github.com/SaraAli26/javascript-questions/blob/master/README.md)
[中文版本](https://github.com/SaraAli26/javascript-questions/blob/master/README-zh_CN.md)
@@ -124,6 +126,7 @@ shape.perimeter();
+
---
4. ماهو الناتج؟
@@ -147,6 +150,7 @@ shape.perimeter();
+
---
5. أي الإجابات هو إجابة صحيحة؟
@@ -182,6 +186,7 @@ const mouse = {
+
---
6. ماهو الناتج؟
@@ -217,6 +222,7 @@ console.log(d.greeting);
+
---
7. ماهو الناتج؟
@@ -252,4 +258,401 @@ console.log(b === c);
+
+---
+
+8. ماهو الناتج؟
+
+```javascript
+class Chameleon {
+ static colorChange(newColor) {
+ this.newColor = newColor;
+ return this.newColor;
+ }
+
+ constructor({ newColor = "green" } = {}) {
+ this.newColor = newColor;
+ }
+}
+
+const freddie = new Chameleon({ newColor: "purple" });
+console.log(freddie.colorChange("orange"));
+```
+
+- A: `orange`
+- B: `purple`
+- C: `green`
+- D: `TypeError`
+
+الإجابة
+
+
+الجواب هو الخيار الرابع: D
+
+الدالة `colorChange` هي دالة static, و الدوال التي هي من نوع static هي دوال صممت لكي يتم استخدامها فقط في الconstructor الذي تم تعريفها به, و ليس من الممكن ان يتم تمريرها او استخدامها من قبل اي مكون children. بما أن `freddie` هي متغير children فإن الدالة لم يتم تمريرها اليه و هي غير متوفرة في ال instant من `freddie` لذا نتحصل على الخطأ `TypeError` .
+
+
+
+
+---
+
+9. ماهو الناتج؟
+
+```javascript
+let greeting;
+greetign = {}; // Typo!
+console.log(greetign);
+```
+
+- A: `{}`
+- B: `ReferenceError: greetign is not defined`
+- C: `undefined`
+
+الإجابة
+
+
+الجواب هو الخيار الأول : A
+
+تقوم بعمل log على الconsole ل object. و لأننا قمنا بإنشاء object فارغ في glopal object! عندما قمنا بالخطأ بطباعة `greetign` بدل ان نقوم بطباعتها بصورة صحيحة هكذا `greeting`, هنا قام مترجم الجافاسكريبت بترجمة الآتي `global.greetign = {}` أو `window.greetign = {}` في المتصفح.
+
+لكي نتجنب حدوث مثل هذه الحالة, بإمكاننا إستخدام `"use strict"`. بفعل هذه الخطوة ستتأكد من أنك قد عرفت المتغير قبل ان تساويه بأي شي آخر.
+
+
+
+
+---
+
+ 10. ما الذي يحدث عندما نقوم بعمل الآتي؟
+
+```javascript
+function bark() {
+ console.log("Woof!");
+}
+
+bark.animal = "dog";
+```
+
+- A: Nothing, this is totally fine!
+- B: `SyntaxError`. You cannot add properties to a function this way.
+- C: `undefined`
+- D: `ReferenceError`
+
+الإجابة
+
+
+الجواب هو الخيار الأول: A
+
+هذا ممكن في لغة الجافاسكريبت, لأن الدوال هي عبارة عن objects, (كل شيء بداخل الأنواع التي هي primitive هو عبارة عن object)
+
+الدالة هي عبارة عن نوع خاص من الobjects, الكود الذي تقوم بكتابته بنفسك هو ليس بالدالة الفعلية, الدالة هي object لديه خصائص. و هذه الخاصية قابلة للمناداة
+
+
+
+
+---
+
+11. ماهو الناتج؟
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const member = new Person("Lydia", "Hallie");
+Person.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+
+console.log(member.getFullName());
+```
+
+- A: `TypeError`
+- B: `SyntaxError`
+- C: `Lydia Hallie`
+- D: `undefined` `undefined`
+
+الإجابة
+
+
+الجواب هو الخيار الأول: A
+
+ليس بإمكانك اضافة الخصائص ل constructor كما تقوم بإضافة الخصائص للobjects. إذا أردت أن تضيف مميزات لكل الobjects مرة واحدة, سيجب عليك أن تقوم بإستخدام الprototype. لذا في هذه الحالة,
+
+
+```js
+Person.prototype.getFullName = function() {
+ return `${this.firstName} ${this.lastName}`;
+};
+```
+
+
+اذا استطعنا جعل `member.getFullName()` تعمل. لماذا ستكون ذات فائدة؟ فلنفترض أننا أضفنا هذه الmethod للconstructor نفسها. ربما ليس أي instance من `Person` تحتاج الى هذه ال method. بهذه الطريقة سنقوم بإستهلاك مساحة كبيرة من الذاكرة, بما أنهم سيظلون يحتفظون ب هذه الخاصية, و التي بدورها ستقوم بحجز مساحة في الذاكرة لأي instance. لذا من الأفضل أن نقوم بإضافتهاالى الprototype, بهذه الطريقة ستقوم بحجز مكان واحد فقط في الذاكرة, و لكنها متاحة للكل للوصول إليها.
+
+
+
+
+---
+
+12. ماهو الناتج؟
+
+```javascript
+function Person(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+}
+
+const lydia = new Person("Lydia", "Hallie");
+const sarah = Person("Sarah", "Smith");
+
+console.log(lydia);
+console.log(sarah);
+```
+
+- A: `Person {firstName: "Lydia", lastName: "Hallie"}` and `undefined`
+- B: `Person {firstName: "Lydia", lastName: "Hallie"}` and `Person {firstName: "Sarah", lastName: "Smith"}`
+- C: `Person {firstName: "Lydia", lastName: "Hallie"}` and `{}`
+- D:`Person {firstName: "Lydia", lastName: "Hallie"}` and `ReferenceError`
+
+
الإجابة
+
+
+الجواب هو الخيار الأول: A
+
+للمتغير `sarah` لم نقم بإستخدام الكلمة المفتاحية `new`, عندإستخدام الكلمة المفتاحية `new` ف هي تشير الى ال object الخالي او الفارغ الذي قمنا بإنشاءه, و لكن اذا لم تقم بإضافة`new` ف هي ستشير الى ال **global object**!.
+
+نحن نقول بأن `this.firstName` تساوي `"Sarah"` و `this.lastName` تساوي `"Smith"`. ماقمنا بفعله حقا هنا, هو أنه قمنا بتعريف `global.firstName = 'Sarah'` و `global.lastName = 'Smith'`. المتغير `sarah` لا يظل `undefined`.
+
+
+
+
+---
+
+13. ماهي الثلاث مراحل التي تمر بها الevent propagation?
+
+- A: Target > Capturing > Bubbling
+- B: Bubbling > Target > Capturing
+- C: Target > Bubbling > Capturing
+- D: Capturing > Target > Bubbling
+
+الإجابة
+
+
+الجواب هو الخيار الرابع: D
+
+أثناء مرحلة ال**capturing**, الevent تمر عبر العناصر العليا, أي العناصر الآباء إلى أن تصل الى العنصر المقصود أو المراد, حينها تتمكن من الوصول الى العنصر **target** , و حينها تبدأ عملية ال **bubbling**.
+
+

+
+
+
+
+
+---
+
+14. جميع الobjects لديها prototypes?
+
+- A: true
+- B: false
+
+الإجابة
+
+
+الجواب هو الخيار الثاني: B
+
+جميع الobjects لديها prototypes, عدا ال objects من نوع **base object**. الobject من نوع base object هو عبارة عن object تم إنشاءه من قبل المستخدم, أو تم إنشاءه عن طريق إستخدام الكلمة المفتاحية `new`. الbase object لديه حق الوصول الى بعض ال methods و الخصائص. مثال: `.toString`. هذا هو السبب الذي يمكنك من إستخدام built-in JavaScript methods, مثل هذه ال methods جميعها متاحة في ال ptototype, على الرغم من أن لغة الجافا سكريبت ليس بإمكانها أن تجدها بصورة مباشرة من الobject الذي قمت أنت بإنشاءه, و لكنها تذهب الى سلسلة الprototype حيث بإمكانها ان تجده هناك, مما يجعله قابل للوصول من قبلك, أي بإمكانك أن تصل إليه.
+
+
+
+
+---
+
+15. ماهو الناتج؟
+
+```javascript
+function sum(a, b) {
+ return a + b;
+}
+
+sum(1, "2");
+```
+
+- A: `NaN`
+- B: `TypeError`
+- C: `"12"`
+- D: `3`
+
+الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+لغة الجافاسكريبت هي لغة **dynamically typed language** بمعنى أننا لا نقوم بتعريف نوع معين للمتغيرات, المتغيرات بصورة أوتوماتيكية يتم تحويلها الى أنواع أخرى بدون أن تعرف أنت ذلك, وهذا يسمى ب _implicit type coercion_. **Coercion** تعني بأنك تقوم بالتحويل من نوع الى آخر.
+
+في هذا المثال, لغة الجافاسكريبت تقوم بتحويل الرقم `1` الى string, لكي تستطيع الدالةأن تقوم بعملها و تتمكن من إرجاع قيمة. أثناء قيام عملية إضافةالمتغير من النوع number و الذي هو (`1`) و المتغير من النوع string والذي هو (`'2'`), الرقم تم التعامل معه ك string, بهذه الطريقة سنتمكن من عمل عملية concatenate للمتغيرين من نوع string ك مثال `"Hello" + "World"`, لهذا مايحدث هنا هو عبارة عن `"1" + "2"` و الذي بدوره يقوم بإرجاع `"12"`.
+
+
+
+
+---
+
+16. ماهو الناتج؟
+
+```javascript
+let number = 0;
+console.log(number++);
+console.log(++number);
+console.log(number);
+```
+
+- A: `1` `1` `2`
+- B: `1` `2` `2`
+- C: `0` `2` `2`
+- D: `0` `1` `2`
+
+الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+ال **postfix** العامل الأحادي `++`:
+
+1. تقوم بإرجاع القيمة (هذه ترجع `0`)
+2. تقوم بزيادةالقيمة (number الآن تساوي `1`)
+
+ال **prefix** العامل الأحادي `++`:
+
+1. تقوم بزيادة القيمة(number الآن تساوي `2`)
+2. تقوم بإٍرجاع القيمة (هذه ترجع `2`)
+
+هذايقوم بإرجاع `0 2 2`.
+
+
+
+
+
+---
+
+17.ماهو الناتج؟
+
+```javascript
+function getPersonInfo(one, two, three) {
+ console.log(one);
+ console.log(two);
+ console.log(three);
+}
+
+const person = "Lydia";
+const age = 21;
+
+getPersonInfo`${person} is ${age} years old`;
+```
+
+- A: `"Lydia"` `21` `["", " is ", " years old"]`
+- B: `["", " is ", " years old"]` `"Lydia"` `21`
+- C: `"Lydia"` `["", " is ", " years old"]` `21`
+
+الإجابة
+
+
+الجواب هو الخيار الثاني: B
+
+اذا قمت بإستخدام tagged template literals, فإن قيمة ال argument الأول هي دائما عبارة عن array والذي نوع قيمها عبارة عن string, ماتبقى من الarguments تتحصل على القيم من الpassed expressions.
+
+
+
+
+---
+
+18. ماهو الناتج؟
+
+```javascript
+function checkAge(data) {
+ if (data === { age: 18 }) {
+ console.log("You are an adult!");
+ } else if (data == { age: 18 }) {
+ console.log("You are still an adult.");
+ } else {
+ console.log(`Hmm.. You don't have an age I guess`);
+ }
+}
+
+checkAge({ age: 18 });
+```
+
+- A: `You are an adult!`
+- B: `You are still an adult.`
+- C: `Hmm.. You don't have an age I guess`
+
+الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+عندما نقوم بإختبار المساواة أو التساوي بين طرفين, ال primitives يتم مقارنتها عن طريق قيمها, بينما ال objects يتم مقارنتها عن طريق الreference الذي يتبع لها, لغة الجافاسكريبت تتحقق عن إذا ماكان الrefrence الذي يتبع لobject يشير الى نفس الموقع في الذاكرة.
+
+لدينا هنا اثنان من ال objects والتي نقوم بعمل مقارنة بينهما, واللذان بدورهما ليس لديهما ذلك, الobject الذي قمنا بتمريره ك parameter يشير الى موقع مختلف في الذاكرة من الموقع الذي يشير اليه الobject الثاني و الذي تم استخدامه للتحق من شرط المساواة.
+
+لهذا كلا من `{ age: 18 } === { age: 18 }` و `{ age: 18 } == { age: 18 }` يرجعان `false`.
+
+
+
+
+
+---
+
+19. ماهو الناتج؟
+
+```javascript
+function getAge(...args) {
+ console.log(typeof args);
+}
+
+getAge(21);
+```
+
+- A: `"number"`
+- B: `"array"`
+- C: `"object"`
+- D: `"NaN"`
+
+الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+العامل spread `...args` يقوم بإرجاع array مع arguments. الarray هي object, لذا فإن `typeof args` تقوم بإرجاع `"object"`.
+
+
+
+
+---
+
+20. ماهو الناتج؟
+
+```javascript
+function getAge() {
+ "use strict";
+ age = 21;
+ console.log(age);
+}
+
+getAge();
+```
+
+- A: `21`
+- B: `undefined`
+- C: `ReferenceError`
+- D: `TypeError`
+
+الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+بإستخدام `"use strict"`, يمكنك التأكد بأنك لن تقوم عن طريق الخطأ بتعريف glopal variables. نحن لم نقم قط بتعريف المتغير `age`, و بما أننا قمنا بإستخدام `"use strict"` ستقوم بإرجاع reference error. اذا لم نقم بإستخدام `"use strict"` لكانت قد أدت المطلوب, بما أن الخاصية `age` تم إضافتها لل glopal object.
+
+
+
+
---
From a677fa7119b3db154dd669229995092d397d6cbd Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Wed, 26 Jun 2019 00:12:48 +0200
Subject: [PATCH 087/881] Right Alignment for Q13-14
---
README_AR.md | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index 8499b16e..c2bdef3f 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -27,7 +27,7 @@
____________
-###### 1. ماهو الناتج ؟
+1. ماهو الناتج ؟
```javascript
function sayHi() {
@@ -428,7 +428,9 @@ console.log(sarah);
---
-13. ماهي الثلاث مراحل التي تمر بها الevent propagation?
+
+13. ماهي الثلاث مراحل التي تمر بها الevent propagation?
+
- A: Target > Capturing > Bubbling
- B: Bubbling > Target > Capturing
@@ -450,7 +452,9 @@ console.log(sarah);
---
+
14. جميع الobjects لديها prototypes?
+
- A: true
- B: false
From 9d2b3464d96f8e7886d1e00d0e8620b36c931def Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Wed, 26 Jun 2019 00:13:58 +0200
Subject: [PATCH 088/881] Update README_AR.md
---
README_AR.md | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index c2bdef3f..eb702eae 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -454,14 +454,13 @@ console.log(sarah);
14. جميع الobjects لديها prototypes?
-
- A: true
- B: false
الإجابة
-
+
الجواب هو الخيار الثاني: B
جميع الobjects لديها prototypes, عدا ال objects من نوع **base object**. الobject من نوع base object هو عبارة عن object تم إنشاءه من قبل المستخدم, أو تم إنشاءه عن طريق إستخدام الكلمة المفتاحية `new`. الbase object لديه حق الوصول الى بعض ال methods و الخصائص. مثال: `.toString`. هذا هو السبب الذي يمكنك من إستخدام built-in JavaScript methods, مثل هذه ال methods جميعها متاحة في ال ptototype, على الرغم من أن لغة الجافا سكريبت ليس بإمكانها أن تجدها بصورة مباشرة من الobject الذي قمت أنت بإنشاءه, و لكنها تذهب الى سلسلة الprototype حيث بإمكانها ان تجده هناك, مما يجعله قابل للوصول من قبلك, أي بإمكانك أن تصل إليه.
From da34d13b0c23143f5bb02a18328f0e0b9391301c Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Wed, 26 Jun 2019 00:20:20 +0200
Subject: [PATCH 089/881] Update README_AR.md
---
README_AR.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README_AR.md b/README_AR.md
index eb702eae..c2bdef3f 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -454,13 +454,14 @@ console.log(sarah);
14. جميع الobjects لديها prototypes?
+
- A: true
- B: false
الإجابة
-
+
الجواب هو الخيار الثاني: B
جميع الobjects لديها prototypes, عدا ال objects من نوع **base object**. الobject من نوع base object هو عبارة عن object تم إنشاءه من قبل المستخدم, أو تم إنشاءه عن طريق إستخدام الكلمة المفتاحية `new`. الbase object لديه حق الوصول الى بعض ال methods و الخصائص. مثال: `.toString`. هذا هو السبب الذي يمكنك من إستخدام built-in JavaScript methods, مثل هذه ال methods جميعها متاحة في ال ptototype, على الرغم من أن لغة الجافا سكريبت ليس بإمكانها أن تجدها بصورة مباشرة من الobject الذي قمت أنت بإنشاءه, و لكنها تذهب الى سلسلة الprototype حيث بإمكانها ان تجده هناك, مما يجعله قابل للوصول من قبلك, أي بإمكانك أن تصل إليه.
From 03c14eac71e507239d0899f36f7b806e03a23e5b Mon Sep 17 00:00:00 2001
From: kimdanah
Date: Wed, 26 Jun 2019 21:40:05 +0900
Subject: [PATCH 090/881] Translate the questions 31-40 to Korean
---
README-ko_KR.md | 73 +++++++++++++++++++++++++------------------------
1 file changed, 37 insertions(+), 36 deletions(-)
diff --git a/README-ko_KR.md b/README-ko_KR.md
index 5df54822..fc0f0834 100644
--- a/README-ko_KR.md
+++ b/README-ko_KR.md
@@ -163,7 +163,7 @@ const mouse = {
#### 정답: A
-JavaScript에서, 모든 객체 키는 문자열이에요 (Symbol이 아닌 한). 비록 그것을 문자열 _타입_ 으로 입력하지 않아도, 항상 내부적으로 문자열로 변환되요.
+JavaScript에서, 모든 객체 키는 문자열이에요 (Symbol이 아닌 한). 비록 그것을 문자열 _형_ 으로 입력하지 않아도, 항상 내부적으로 문자열로 변환되요.
JavaScript는 문장을 해석(또는 박스해제)해요. 대괄호 표기를 사용하면, 첫 번째 좌대괄호 `[`를 보고 오른쪽 대괄호 `]`를 찾을 때까지 진행해요. 그때, 그 문장을 평가할거에요.
@@ -239,7 +239,7 @@ console.log(b === c);
`==`연산자를 사용할 때, 그건 같은 _값_ 을 가지고 있는지 여부만 확인해요. 그것들은 모두`3`의 값을 가지고 있으므로, `true`를 리턴해요.
-그러나, `===`연산자를 사용할 때, 값 _과_ 타입 둘다 같아야 해요. 이건 아니에요: `new Number()`는 숫자가 아니에요. **객체**에요. 그래서 둘다 `false`를 리턴해요.
+그러나, `===`연산자를 사용할 때, 값 _과_ 형 둘다 같아야 해요. 이건 아니에요: `new Number()`는 숫자가 아니에요. **객체**에요. 그래서 둘다 `false`를 리턴해요.
@@ -363,7 +363,7 @@ console.log(member.getFullName());
#### 정답: A
-보통의 객체처럼 생성자에는 속성을 추가할 수 없어요. 한 번에 모든 객체에 기능을 추가하고 싶다면, 프로토 타입을 사용해야 해요. 그래서 이 경우에,
+보통의 객체처럼 생성자에는 속성을 추가할 수 없어요. 한 번에 모든 객체에 기능을 추가하고 싶다면, 프로토타입을 사용해야 해요. 그래서 이 경우에,
```js
Person.prototype.getFullName = function() {
@@ -470,7 +470,7 @@ sum(1, "2");
#### 정답: C
-JavaScript는 **동적으로 만들어진 언어**에요: 특정변수가 어떤 타입인지 지정하지 않아요. 변수는 당신이 모르는 사이에 자동으로 다른 타입으로 변환 될 수 있는데, 이걸 _암묵적 타입 변환_ 이라고 불러요. **Coercion**은 하나의 타입을 다른 타입으로 변환하는 거에요.
+JavaScript는 **동적으로 만들어진 언어**에요: 특정변수가 어떤 형인지 지정하지 않아요. 변수는 당신이 모르는 사이에 자동으로 다른 형으로 변환 될 수 있는데, 이걸 _암묵적 형 변환_ 이라고 불러요. **Coercion**은 하나의 형을 다른 형으로 변환하는 거에요.
이 예제에서, 함수가 이해하고 값을 리턴하도록, JavaScript는 숫자 `1`을 문자열로 변환해요. 수형 (`1`)와 문자열형 (`'2'`)의 추가 중에는, 숫자는 문자열로 취급되요. `"Hello" + "World"`처럼 문자열을 연결할 수 있어요, 따라서 여기 `"1" + "2"`는 `"12"`을 리턴하는 일이 발생해요.
@@ -932,7 +932,7 @@ WebAPI는 준비가 될때 마다 stack에 항목을 추가 할 수 없어요.
---
-###### 31. What is the event.target when clicking the button?
+###### 31. 버튼을 클릭했을때 event.target은 무엇일까요?
```html
@@ -944,24 +944,24 @@ WebAPI는 준비가 될때 마다 stack에 항목을 추가 할 수 없어요.
```
-- A: Outer `div`
-- B: Inner `div`
+- A: 외부의 `div`
+- B: 내부의 `div`
- C: `button`
-- D: An array of all nested elements.
+- D: 중첩된 모든 요소의 배열
정답
#### 정답: C
-The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+가장 깊이 중첩된 요소가 이벤트를 발생시킬 이벤트 대상이에요. `event.stopPropagation`을 통해서 버블링을 중단 할 수 있어요.
---
-###### 32. When you click the paragraph, what's the logged output?
+###### 32. p태그를 클릭하면 로그의 출력은 무엇일까요 ?
```html
@@ -981,7 +981,7 @@ The deepest nested element that caused the event is the target of the event. You
#### 정답: A
-If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
+`p`를 클릭하면, 2개의 로그를 볼 수 있어요: `p` 그리고 `div`. 이벤트의 전파 중에는 3 단계가 있어요: 캡처링, 타켓, 버블링. 기본적으로, 이벤트 핸들러는 버블링단계에서 시작되요. (`useCapture`를 `true`로 설정하지 않는 한). 가장 깊게 중첩된 요소로 부터 바깥쪽으로 나가요.
@@ -1011,9 +1011,9 @@ sayHi.bind(person, 21);
#### 정답: D
-With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
+두개 모두, `this`키워드를 참조하고자하는 객체로 보낼 수 있어요. 그러나, `.call`은 _즉시 실행되요_!
-`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
+`.bind.`는 함수의 _복사본_ 을 리턴하지만, 바인딩 컨텍스트에요! 이건 즉시 실행되지 않아요.
@@ -1040,16 +1040,16 @@ typeof sayHi();
#### 정답: B
-The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+`sayHi`함수는 즉시 호출 함수(IIFE)로서 리턴된 값을 리턴해요. 이 함수는 `0`을 리턴하고, 형은 `"number"`이에요.
-FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+참고: 단 7개의 내장형이 있어요: `null`, `undefined`, `boolean`, `number`, `string`, `object` 그리고 `symbol`. `"function"`은 객체이기 때문에 형이아니라 `"object"` 형이에요.
---
-###### 35. Which of these values are falsy?
+###### 35. 이 값들 중 어느 것이 거짓 같은 값 일까요?
```javascript
0;
@@ -1063,23 +1063,23 @@ undefined;
- A: `0`, `''`, `undefined`
- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
- C: `0`, `''`, `new Boolean(false)`, `undefined`
-- D: All of them are falsy
+- D: 모든 값은 거짓
정답
#### 정답: A
-There are only six falsy values:
+단 6개의 거짓 값이 있어요:
- `undefined`
- `null`
- `NaN`
- `0`
-- `''` (empty string)
+- `''` (빈 문자열)
- `false`
-Function constructors, like `new Number` and `new Boolean` are truthy.
+`new Number` 그리고 `new Boolean`와 같은 생성자 함수는 참같은 값이에요.
@@ -1102,8 +1102,8 @@ console.log(typeof typeof 1);
#### 정답: B
-`typeof 1` returns `"number"`.
-`typeof "number"` returns `"string"`
+`typeof 1` 은 `"number"`을 리턴해요.
+`typeof "number"`은 `"string"`을 리턴해요.
@@ -1128,11 +1128,12 @@ console.log(numbers);
#### 정답: C
-When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like:
+배열의 길이를 초과한 값을 배열의 요소로 설정하고자 할때, JavaScript는 "empty slots"이라고 불리는 것을 생성해요. 이것은 실제로 `undefined`의 값을 가지고 있지만, 다음과 같은 것을 보게 될거에요:
`[1, 2, 3, 7 x empty, 11]`
depending on where you run it (it's different for every browser, node, etc.)
+실행 위치에 따라 달라요 (브라우저, node 등마다 달라요.)
@@ -1165,34 +1166,34 @@ depending on where you run it (it's different for every browser, node, etc.)
#### 정답: A
-The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
+`catch`블록은 `x`의 인자를 받아요. 이것은 인수를 전달할때 변수로서의 `x`와는 달라요. 이 `x` 변수는 블록-스코프에요.
-Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+후에, 블록-스코프 변수는 `1`로 설정하고, 변수 `y`의 값을 설정해요. 여기서, 블록-스코프의 변수 `x`를 출력하는데, 이것은 `1`이에요.
-Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+`catch` 블록 밖에서, `x`는 여전히 `undefined`이고 `y`는 `2`이에요. `catch` 블록 밖에서 `console.log(x)`를 출력하면, `undefined`을 리턴하고. 그리고 `y`는 `2`를 리턴해요.
---
-###### 39. Everything in JavaScript is either a...
+###### 39. JavaScript의 모든 것은...
-- A: primitive or object
-- B: function or object
-- C: trick question! only objects
-- D: number or object
+- A: primitive 또는 object
+- B: function 또는 object
+- C: 함정 문제! objects만
+- D: number 또는 object
정답
#### 정답: A
-JavaScript only has primitive types and objects.
+JavaScript는 원시형과 객체만 가지고 있어요.
-Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+원시형은 `boolean`, `null`, `undefined`, `bigint`, `number`, `string` 그리고 `symbol`이 있어요.
-What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+원시형과 객체를 구별하는 법은 원시형에는 속성이나 메소드가 없어요. 그러나 `'foo'.toUpperCase()`는 `'FOO'`로 평가되어, `TypeError`의 결과가 되지 않아요. 문자열과 같은 원시형이 속성 또는 메소드에 접근하려고 할때, JavaScript는 래퍼 클래스 중 하나인 `String`을 사용하여 암묵적으로 감싸고, 표현식이 평가된 후 즉시 래퍼를 폐기하기 때문이에요. `null` 그리고 `undefined`를 제외한 모든 원시형은 이러한 행동을 합니다.
@@ -1220,9 +1221,9 @@ What differentiates a primitive from an object is that primitives do not have an
#### 정답: C
-`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
+`[1, 2]`은 초기값이에요. 이것이 최초의 값으로, 제일 처음의 `acc`의 값이에요. 처음 라운드 동안에 `acc`은 `[1,2]`이며, `cur`은 `[0, 1]`이에요. 그것들을 연결하면 결과적으로 `[1, 2, 0, 1]`이 되요.
-Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
+그리고나서, `[1, 2, 0, 1]`은 `acc`이고, `[2, 3]`은 `cur`이 에요. 그것들을 연결하면 `[1, 2, 0, 1, 2, 3]`을 얻게되요.
From a6a847962c9c1383faed951af6f6e54d7d512eea Mon Sep 17 00:00:00 2001
From: kimdanah
Date: Wed, 26 Jun 2019 21:58:28 +0900
Subject: [PATCH 091/881] Corrects for spelling
---
README-ko_KR.md | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/README-ko_KR.md b/README-ko_KR.md
index fc0f0834..0b3ac688 100644
--- a/README-ko_KR.md
+++ b/README-ko_KR.md
@@ -40,7 +40,7 @@ sayHi();
#### 정답: D
-함수내에서, 우선 `var`키워드를 사용해 `name`변수를 선언해요. 이것은 변수가 정의되어 있는 행에 실제로 도달할 때까지, 변수는 `undefined`을 기본값으로 호이스팅 된(생성단계에 메모리 공간이 설정됨)는 것을 의미해요. `name`변수를 출력 하려는 줄에서 아직 변수를 정의하고 있지 않았기 때문에, `undefined`값을 유지하고 있어요.
+함수내에서, 우선 `var`키워드를 사용해 `name`변수를 선언해요. 이것은 변수가 정의되어 있는 행에 실제로 도달할 때까지, 변수는 `undefined`을 기본값으로 호이스팅 되(생성단계에 메모리 공간이 설정됨)는 것을 의미해요. `name` 변수를 출력 하려는 줄에서 아직 변수를 정의하고 있지 않기 때문에, `undefined`값을 유지하고 있어요.
`let`키워드(그리고 `const`)를 가지는 변수들은, `var`와는 달리, 호이스팅되지만 초기화되지 않아요. 그것들을 선언(초기화)하는 줄 전에는 접근 할 수 없어요. 이것은 "일시적 사각지대"라고 불려요. 선언되기 전에 변수에 접근하려고 하면, JavaScript는 `ReferenceError`를 던져요.
@@ -736,8 +736,7 @@ set.has(1);
#### 정답: C
-모든 객체 키(Symbols 제외)
-모든 객체 키는(Symbol 제외) 문자열로 직접 입력하지 않아도, 내부적으로는 문자열이에요. 이것이 `obj.hasOwnProperty('1')` 또한 true를 리턴하는 이유에요.
+모든 객체 키는(Symbol 제외) 문자열로 직접 입력하지 않아도, 내부적으로는 문자열이에요. 이것이 `obj.hasOwnProperty('1')` 또한 true를 리턴하는 이유에요.
set에서는 작동하지 않아요. set에는 `'1'`이 없어요: `set.has('1')`는 `false`를 리턴해요. 그것은 수형인 `1`을 가지고 있어, `set.has(1)`은 `true`를 리턴해요.
@@ -1128,12 +1127,12 @@ console.log(numbers);
#### 정답: C
-배열의 길이를 초과한 값을 배열의 요소로 설정하고자 할때, JavaScript는 "empty slots"이라고 불리는 것을 생성해요. 이것은 실제로 `undefined`의 값을 가지고 있지만, 다음과 같은 것을 보게 될거에요:
+배열의 길이를 초과한 값을 배열의 요소로 설정하고자 할때, JavaScript는 "empty slots"이라고 불리는 것을 생성해요. 이것은 실제로 `undefined`의 값을 가지고 있지만, 다음과 같은 것을 보게 될거에요:
`[1, 2, 3, 7 x empty, 11]`
depending on where you run it (it's different for every browser, node, etc.)
-실행 위치에 따라 달라요 (브라우저, node 등마다 달라요.)
+실행 위치에 따라 달라요 (브라우저, node 등 마다 달라요.)
@@ -1177,11 +1176,11 @@ depending on where you run it (it's different for every browser, node, etc.)
---
-###### 39. JavaScript의 모든 것은...
+###### 39. JavaScript의 모든 것은...
- A: primitive 또는 object
- B: function 또는 object
-- C: 함정 문제! objects만
+- C: 함정 문제! objects만
- D: number 또는 object
정답
@@ -1193,7 +1192,7 @@ JavaScript는 원시형과 객체만 가지고 있어요.
원시형은 `boolean`, `null`, `undefined`, `bigint`, `number`, `string` 그리고 `symbol`이 있어요.
-원시형과 객체를 구별하는 법은 원시형에는 속성이나 메소드가 없어요. 그러나 `'foo'.toUpperCase()`는 `'FOO'`로 평가되어, `TypeError`의 결과가 되지 않아요. 문자열과 같은 원시형이 속성 또는 메소드에 접근하려고 할때, JavaScript는 래퍼 클래스 중 하나인 `String`을 사용하여 암묵적으로 감싸고, 표현식이 평가된 후 즉시 래퍼를 폐기하기 때문이에요. `null` 그리고 `undefined`를 제외한 모든 원시형은 이러한 행동을 합니다.
+원시형과 객체를 구별하는 법은 원시형에는 속성이나 메소드가 없어요. 그러나 `'foo'.toUpperCase()`는 `'FOO'`로 평가되어, `TypeError`의 결과가 되지 않아요. 문자열과 같은 원시형이 속성 또는 메소드에 접근하려고 할때, JavaScript는 래퍼 클래스 중 하나인 `String`을 사용하여 암묵적으로 감싸고, 표현식이 평가된 후 즉시 래퍼를 폐기하기 때문이에요. `null` 그리고 `undefined`를 제외한 모든 원시형은 이러한 행동을 합니다.
From 85cf3c14257f67fee8f25afe7818c1b197dda429 Mon Sep 17 00:00:00 2001
From: kimdanah
Date: Thu, 27 Jun 2019 20:23:24 +0900
Subject: [PATCH 092/881] Reset README.md from original & Translate the
questions 41-43 to Korean
---
README-ko_KR.md | 30 ++++++++++++++++--------------
README.md | 25 ++++++++++++-------------
2 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/README-ko_KR.md b/README-ko_KR.md
index 0b3ac688..909e7f48 100644
--- a/README-ko_KR.md
+++ b/README-ko_KR.md
@@ -7,13 +7,15 @@ JavaScript 에 관한 객관식 문제를 [Instagram](https://www.instagram.com/
정답은 질문 아래 접힌 부분에 있어요, 그냥 클릭하면 펼칠 수 있어요. 행운을 빌어요 :heart:
[中文版本](./README-zh_CN.md)
+[Versión en español](./README-ES.md)
+[日本語](./README-ja_JA.md)
+[한국어](./README-ko_KR.md)
[Русский](./README_ru-RU.md)
[Western Balkan](./README-bs_BS.md)
[Deutsch](./README-de_DE.md)
[Tiếng Việt](./README-vi.md)
-[日本語](./README-ja_JA.md)
[Українська мова](./README-ua_UA.md)
-[한국어](./README-ko_KR.md)
+[Português Brasil](./README_pt_BR.md)
---
@@ -1247,26 +1249,26 @@ JavaScript는 원시형과 객체만 가지고 있어요.
#### 정답: B
-`null` is falsy. `!null` returns `true`. `!true` returns `false`.
+`null`은 거짓 같은 값이에요. `!null`은 `true`를 리턴해요. `!true`은 `false`를 리턴해요.
-`""` is falsy. `!""` returns `true`. `!true` returns `false`.
+`""` 은 거짓 같은 값이에요. `!""`은 `true`를 리턴해요. `!true`은 `false`를 리턴해요.
-`1` is truthy. `!1` returns `false`. `!false` returns `true`.
+`1`은 참 같은 값이에요. `!1`은 `false`를 리턴해요. `!false`는`true`를 리턴해요.
---
-###### 42. What does the `setInterval` method return in the browser?
+###### 42. `setInterval` 메소드는 브라우저에게 무엇을 리턴 할까요?
```javascript
setInterval(() => console.log("Hi"), 1000);
```
-- A: a unique id
-- B: the amount of milliseconds specified
-- C: the passed function
+- A: 유니크한 id
+- B: 지정된 밀리초
+- C: 통과된 함수
- D: `undefined`
정답
@@ -1274,14 +1276,14 @@ setInterval(() => console.log("Hi"), 1000);
#### 정답: A
-It returns a unique id. This id can be used to clear that interval with the `clearInterval()` function.
+이것은 유니크한 id를 리턴해요. 이 id는 `clearInterval()` 함수로 간격을 없애기 위해 사용 될 수 있어요.
---
-###### 43. What does this return?
+###### 43. 이것은 무엇을 리턴할까요?
```javascript
[..."Lydia"];
@@ -1297,7 +1299,7 @@ It returns a unique id. This id can be used to clear that interval with the `cle
#### 정답: A
-A string is an iterable. The spread operator maps every character of an iterable to one element.
+문자열은 반복 가능한 객체에요. 스프레드 연산자는 반복 가능한 객체의 모든 문자를 1개의 요소로 매핑해요.
@@ -1339,7 +1341,7 @@ Then, we invoke the function again with the `next()` method. It starts to contin
---
-###### 45. What does this return?
+###### 45. 이것은 무엇을 리턴할까요?
```javascript
const firstPromise = new Promise((res, rej) => {
@@ -1363,7 +1365,7 @@ Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
#### 정답: B
-When we pass multiple promises to the `Promice.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged.
+When we pass multiple promises to the `Promise.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged.
diff --git a/README.md b/README.md
index 840b9b7c..e58fa2ac 100644
--- a/README.md
+++ b/README.md
@@ -7,17 +7,16 @@ From basic to advanced: test how well you know JavaScript, refresh your knowledg
The answers are in the collapsed sections below the questions, simply click on them to expand it. Good luck :heart:
List of available languages:
-
-- [中文版本](./README-zh_CN.md)
-- [Versión en español](./README-ES.md)
-- [日本語](./README-ja_JA.md)
-- [한국어](./README-ko_KR.md)
-- [Русский](./README_ru-RU.md)
-- [Western Balkan](./README-bs_BS.md)
-- [Deutsch](./README-de_DE.md)
-- [Tiếng Việt](./README-vi.md)
-- [Українська мова](./README-ua_UA.md)
-- [Português Brasil](./README_pt_BR.md)
+* [中文版本](./README-zh_CN.md)
+* [Versión en español](./README-ES.md)
+* [日本語](./README-ja_JA.md)
+* [한국어](./README-ko_KR.md)
+* [Русский](./README_ru-RU.md)
+* [Western Balkan](./README-bs_BS.md)
+* [Deutsch](./README-de_DE.md)
+* [Tiếng Việt](./README-vi.md)
+* [Українська мова](./README-ua_UA.md)
+* [Português Brasil](./README_pt_BR.md)
---
@@ -180,6 +179,7 @@ However, with dot notation, this doesn't happen. `mouse` does not have a key cal
---
+
###### 6. What's the output?
```javascript
@@ -1041,7 +1041,6 @@ console.log(typeof sayHi());
The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
-
@@ -1656,4 +1655,4 @@ Then, we declare a variable `x` with the value of `y`, which is `10`. Variables
However, we created a global variable `y` when setting `y` equal to `10`. This value is accessible anywhere in our code. `y` is defined, and holds a value of type `"number"`. `console.log(typeof y)` returns `"number"`.
-
+
\ No newline at end of file
From 3235c42a3f3943a2f96e0d15f832a5a47fbaf582 Mon Sep 17 00:00:00 2001
From: kimdanah
Date: Thu, 27 Jun 2019 20:46:40 +0900
Subject: [PATCH 093/881] =?UTF-8?q?Remove=20=ED=95=9C=EA=B5=AD=EC=96=B4,?=
=?UTF-8?q?=20Add=20English=20and=20fix=20typo=20from=20original?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README-ko_KR.md | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/README-ko_KR.md b/README-ko_KR.md
index 909e7f48..a30ea659 100644
--- a/README-ko_KR.md
+++ b/README-ko_KR.md
@@ -6,16 +6,16 @@ JavaScript 에 관한 객관식 문제를 [Instagram](https://www.instagram.com/
정답은 질문 아래 접힌 부분에 있어요, 그냥 클릭하면 펼칠 수 있어요. 행운을 빌어요 :heart:
-[中文版本](./README-zh_CN.md)
-[Versión en español](./README-ES.md)
-[日本語](./README-ja_JA.md)
-[한국어](./README-ko_KR.md)
-[Русский](./README_ru-RU.md)
-[Western Balkan](./README-bs_BS.md)
-[Deutsch](./README-de_DE.md)
-[Tiếng Việt](./README-vi.md)
-[Українська мова](./README-ua_UA.md)
-[Português Brasil](./README_pt_BR.md)
+- [English](./README.md)
+- [中文版本](./README-zh_CN.md)
+- [Versión en español](./README-ES.md)
+- [日本語](./README-ja_JA.md)
+- [Русский](./README_ru-RU.md)
+- [Western Balkan](./README-bs_BS.md)
+- [Deutsch](./README-de_DE.md)
+- [Tiếng Việt](./README-vi.md)
+- [Українська мова](./README-ua_UA.md)
+- [Português Brasil](./README_pt_BR.md)
---
@@ -263,7 +263,7 @@ class Chameleon {
}
const freddie = new Chameleon({ newColor: "purple" });
-freddie.colorChange("orange");
+console.log(freddie.colorChange("orange"));
```
- A: `orange`
@@ -445,7 +445,7 @@ console.log(sarah);
#### 정답: B
-**기본객체**를 제외한, 모든 객체는 프로포타입을 가져요. 기본객체는 `.toString`와 같은 몇개의 메소드와 속성에 접근할 수 있어요. 이것이 내장 JavaScript 메소드를 사용할 수 있는 이유죠! 이러한 모든 메소드는 프로토 타입에서 이용 할 수 있어요. JavaScript가 당신의 객체를 직접 찾을 수 없더라도, 당신이 접근 할 수 있도록, 프로토타입 체인으로 내려가서 찾을거에요.
+**기본객체**를 제외한, 모든 객체는 프로포타입을 가져요. 기본객체는 사용자에 의해 만들어지거나 `new`키워드를 사용하여 만들어져요. 기본객체는 `.toString`와 같은 몇개의 메소드와 속성에 접근할 수 있어요. 이것이 내장 JavaScript 메소드를 사용할 수 있는 이유죠! 이러한 모든 메소드는 프로토 타입에서 이용 할 수 있어요. JavaScript가 당신의 객체를 직접 찾을 수 없더라도, 당신이 접근 할 수 있도록, 프로토타입 체인으로 내려가서 찾을거에요.
@@ -1028,7 +1028,7 @@ function sayHi() {
return (() => 0)();
}
-typeof sayHi();
+console.log(typeof sayHi());
```
- A: `"object"`
From 95d196bae1c750c418ddb08735942d9ed0ca554b Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Thu, 27 Jun 2019 14:51:45 +0200
Subject: [PATCH 094/881] Questions 21 - 30 Translated to Arabic
---
README_AR.md | 596 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 596 insertions(+)
diff --git a/README_AR.md b/README_AR.md
index c2bdef3f..a1946e7e 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -660,3 +660,599 @@ getAge();
---
+
+
+21. ماهي القيمة التي تحملها `sum`؟
+
+
+```javascript
+const sum = eval("10*10+5");
+```
+
+- A: `105`
+- B: `"105"`
+- C: `TypeError`
+- D: `"10*10+5"`
+
+الأجابة
+
+
+الجواب هو الخيار الأول : A
+
+`eval` تقوم بتقييم الكود الذي تم تمريره ك string. إذا كان عبارة عن expression كما في هذه الحالة, فإنها تقوم بتقييم ال expression. ال expression هو `10 * 10 + 5`. و هذا بدوره يقوم بإرجاع الرقم `105`.
+
+
+
+
+---
+
+
+22. الى كم من المدة الزمنية ستكون "cool_secret" قابلة للوصول إليها؟
+
+
+```javascript
+sessionStorage.setItem("cool_secret", 123);
+```
+
+A - الى الأبد, فالبيانات لايمكن أن تفقد.
+B - عندما يقوم المستخدم بقفل ال tab.
+C - عندما يقوم المستخدم بقفل نافذه المتصفح , ليس فقط الtab.
+D - عندما يقوم المستخدم بقفل جهاز الكمبيوتر.
+
+
+الإجابة
+
+
+الجواب هو الخيار الثاني: B
+
+البيانات التي يتم تخزينها في `sessionStorage` يتم فقدها بعد قفل ال tab.
+
+إذا قمت بإستخدام `localStorage`, البيانات ستكون مخزنة هناك الى الأبد, و لكن اذا قمت بإستثناء ان تقوم بمناداة الدالة Clear كما في التالي `localStorage.clear()` عندها ستفقد هذه البيانات.:
+
+
+
+
+---
+
+23. ماهو الناتج؟
+
+```javascript
+var num = 8;
+var num = 10;
+
+console.log(num);
+```
+
+- A: `8`
+- B: `10`
+- C: `SyntaxError`
+- D: `ReferenceError`
+
+الإجابة
+
+
+الجواب هو الخيار الثاني: B
+
+مع الكلمة المفتاحية `var` بإمكانك تريف عدد من المتغيرات تحمل نفس الإسم, و المتغير سيقوم بأخذ آخر قيمة تمت إضافتها اليه.
+
+ليس بإمكانك أن تفعل هذا مع `let` أو `const` بما أن الكلمتان المفتاحيتان عبارة عن block-scoped, بمعنى أن القيمة ستكون متاحة في نطاق الBlock الذي تم تعريفها به.
+
+
+
+
+---
+
+24. ماهو الناتج؟
+
+```javascript
+const obj = { 1: "a", 2: "b", 3: "c" };
+const set = new Set([1, 2, 3, 4, 5]);
+
+obj.hasOwnProperty("1");
+obj.hasOwnProperty(1);
+set.has("1");
+set.has(1);
+```
+
+- A: `false` `true` `false` `true`
+- B: `false` `true` `true` `true`
+- C: `true` `true` `false` `true`
+- D: `true` `true` `true` `true`
+
+الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+كل مفاتيح ال object (عدا الSymbols)هي عبارة عن strings وراء الكواليس, حتى لو لم تقم بكتابة ذلك صراحة بنفسك ك string, لهذا دائما `obj.hasOwnProperty('1')` تقوم بإرجاع القيمة true.
+
+ولكنها لا تعمل بهذا الشكل مع set, ليس هنالك `'1'` من ضمن set, لهذا `set.has('1')` تقوم بإرجاع `false`, لديها القيمة الرقمية `1` أي من النوع number, `set.has(1)` تقوم بإرجاع `true`.
+
+
+
+
+---
+
+25. ماهو الناتج؟
+
+```javascript
+const obj = { a: "one", b: "two", a: "three" };
+console.log(obj);
+```
+
+- A: `{ a: "one", b: "two" }`
+- B: `{ b: "two", a: "three" }`
+- C: `{ a: "three", b: "two" }`
+- D: `SyntaxError`
+
+الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+إذا كان لديك مفتاحان يحملان نفس الاسم, فإن المفتاح سيتم تبديله, سيكون المفتاح في نفس مكانه, ولكنه سيحمل فقط القيمة الأخيرة
+
+
+
+
+---
+
+
+26. في سياق تنفيذ glopal في لغة الجافاسكريبت, فإن الجافاسكريبت تقوم بإنشاء شيئين لك: الglopal object و الكلمة المفتاحية "this".
+
+
+- A: true
+- B: false
+- C: تعتمد على
+
+الإجابة
+
+
+الجواب هو الخيارالأول: A
+
+سياق التنفيذ الأساسي هو سياق تنفيذ الglopal, وهي الشيء الذي يمكن الوصول إليه من أي مكان في الكود الذي ببرنامجك.
+
+
+
+
+---
+
+27. ماهو الناتج؟
+
+```javascript
+for (let i = 1; i < 5; i++) {
+ if (i === 3) continue;
+ console.log(i);
+}
+```
+
+- A: `1` `2`
+- B: `1` `2` `3`
+- C: `1` `2` `4`
+- D: `1` `3` `4`
+
+الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+العبارة `continue` تقوم بتخطي دورة التكرار إذا وجد شرط معين يقوم بإرجاع `true`.
+
+
+
+
+---
+
+28. ماهو الناتج؟
+
+```javascript
+String.prototype.giveLydiaPizza = () => {
+ return "Just give Lydia pizza already!";
+};
+
+const name = "Lydia";
+
+name.giveLydiaPizza();
+```
+
+- A: `"Just give Lydia pizza already!"`
+- B: `TypeError: not a function`
+- C: `SyntaxError`
+- D: `undefined`
+
+الإجابة
+
+
+الجواب هو الخيار الأول : A
+
+`String` هي built-in constructor, و لهذا سنتمكن من إضافة خصائص لها. لقد قمت بإضافة method للprototype الخاص ب `String`. Primitive strings يتمتحويلهم بصورة اوتوماتيكية الى objects من نوع string, و التي بدورها تم انشائها عن طريق دالة ال string prototype, لهذا جميع الstrings و التي هي string objects لديها حق الوصول الى الmethod.
+
+
+
+
+---
+
+29. ماهو الناتج؟
+
+```javascript
+const a = {};
+const b = { key: "b" };
+const c = { key: "c" };
+
+a[b] = 123;
+a[c] = 456;
+
+console.log(a[b]);
+```
+
+- A: `123`
+- B: `456`
+- C: `undefined`
+- D: `ReferenceError`
+
+الإجابة
+
+
+الجواب هو الخيار الثاني : B
+
+مفاتيح ال object يتم تحويلها اوتوماتيكيا الى strings. نحن نحاول أن نقوم بجعل object عبارة عن مفتاح للobject `a`, و الذي يحمل القيمة `123`.
+
+و لكن, عندما نقوم بمحاول جعل object الى نوع string, سيصبح `"[Object object]"`. لذا ما نحاول أن نقوله هنا, هو أن `a["Object object"] = 123`.
+إذا, سنحاول أن نفعل هذا مرة أخرى , `c` هو object آخر سنقوم بتحويله الى string بصورة صريحة, لذا `a["Object object"] = 456`.
+
+إذاَ, نحن نقوم بعمل log ل `a[b]`, و التي هي في الحقيقة `a["Object object"]`. و نحن قبل قليل قمنا بوضع قيمتها التي تساوي `456`, لذا ستقوم بإرجاع `456`.
+
+
+
+
+---
+
+30. ماهو الناتج؟
+
+```javascript
+const foo = () => console.log("First");
+const bar = () => setTimeout(() => console.log("Second"));
+const baz = () => console.log("Third");
+
+bar();
+foo();
+baz();
+```
+
+- A: `First` `Second` `Third`
+- B: `First` `Third` `Second`
+- C: `Second` `First` `Third`
+- D: `Second` `Third` `First`
+
+الإجابة
+
+
+الجوا ب هو الخيار الثاني: B
+
+لدينا الدالة `setTimeout` والتي تم استدعائها أولا, و لكن تم الخروج منها آخراً.
+
+هذا لأن في المتصفح, ليس لدينا محرَك من نوع runtime, أيضا لدينا مايعرف ب `WebAPI`. هذا ال`WebAPI` يقوم بإعطائنا الدالة `setTimeout` لكي نبدأ بها, على سبيل المثال: DOM.
+
+بعد ان يتم ارسال و البدء بتنفيذ ال _callback_ الى الWebAPI, الدالة `setTimeout` نفسها (ليس ال callback!) يتم اخراجها من الstack.
+
+

+
+الآن, `foo` يتم إدخالها و البدء بتنفيذها, بينما `"First"` يتم تسجيل دخولها.
+
+

+
+`foo` يتم إخراجها من ال stack, بينما `baz` يتم إدخالها و البدأ بتنفيذها. `"Third"` يتم تسجيل دخولها.
+
+

+
+ال WebAPI ليس بإمكانها إضافة أشياء الى ال stack عندما تكون جاهزة. في المقابل, هي تقوم بإدخال دالة الcallback الى شيء يسمى بال _queue_.
+
+

+
+هنا تحديدا المكان الذي تبدأ فيه الloop بالعمل.
+ال **event loop** تنظر الى الstack و ال task queue, إذا كانت الstack خاوية, فهي تقوم بأخذ أول شيء في الqueue. و تقوم بإدخاله الى stack.
+
+

+
+`bar` يتم إدخالها و البدأ بتنفيذها, `"Second"` يتم تسجيل دخولها, و من ثم إخراجها من الstack.
+
+
+
+
+---
+
+###### 31. What is the event.target when clicking the button?
+
+```html
+
+```
+
+- A: Outer `div`
+- B: Inner `div`
+- C: `button`
+- D: An array of all nested elements.
+
+Answer
+
+
+#### Answer: C
+
+The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+
+
+
+
+---
+
+###### 32. When you click the paragraph, what's the logged output?
+
+```html
+
+```
+
+- A: `p` `div`
+- B: `div` `p`
+- C: `p`
+- D: `div`
+
+Answer
+
+
+#### Answer: A
+
+If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
+
+
+
+
+---
+
+###### 33. What's the output?
+
+```javascript
+const person = { name: "Lydia" };
+
+function sayHi(age) {
+ console.log(`${this.name} is ${age}`);
+}
+
+sayHi.call(person, 21);
+sayHi.bind(person, 21);
+```
+
+- A: `undefined is 21` `Lydia is 21`
+- B: `function` `function`
+- C: `Lydia is 21` `Lydia is 21`
+- D: `Lydia is 21` `function`
+
+Answer
+
+
+#### Answer: D
+
+With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
+
+`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
+
+
+
+
+---
+
+###### 34. What's the output?
+
+```javascript
+function sayHi() {
+ return (() => 0)();
+}
+
+console.log(typeof sayHi());
+```
+
+- A: `"object"`
+- B: `"number"`
+- C: `"function"`
+- D: `"undefined"`
+
+Answer
+
+
+#### Answer: B
+
+The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+
+FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+
+
+
+---
+
+###### 35. Which of these values are falsy?
+
+```javascript
+0;
+new Number(0);
+("");
+(" ");
+new Boolean(false);
+undefined;
+```
+
+- A: `0`, `''`, `undefined`
+- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
+- C: `0`, `''`, `new Boolean(false)`, `undefined`
+- D: All of them are falsy
+
+Answer
+
+
+#### Answer: A
+
+There are only six falsy values:
+
+- `undefined`
+- `null`
+- `NaN`
+- `0`
+- `''` (empty string)
+- `false`
+
+Function constructors, like `new Number` and `new Boolean` are truthy.
+
+
+
+
+---
+
+###### 36. What's the output?
+
+```javascript
+console.log(typeof typeof 1);
+```
+
+- A: `"number"`
+- B: `"string"`
+- C: `"object"`
+- D: `"undefined"`
+
+Answer
+
+
+#### Answer: B
+
+`typeof 1` returns `"number"`.
+`typeof "number"` returns `"string"`
+
+
+
+
+---
+
+###### 37. What's the output?
+
+```javascript
+const numbers = [1, 2, 3];
+numbers[10] = 11;
+console.log(numbers);
+```
+
+- A: `[1, 2, 3, 7 x null, 11]`
+- B: `[1, 2, 3, 11]`
+- C: `[1, 2, 3, 7 x empty, 11]`
+- D: `SyntaxError`
+
+Answer
+
+
+#### Answer: C
+
+When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like:
+
+`[1, 2, 3, 7 x empty, 11]`
+
+depending on where you run it (it's different for every browser, node, etc.)
+
+
+
+
+---
+
+###### 38. What's the output?
+
+```javascript
+(() => {
+ let x, y;
+ try {
+ throw new Error();
+ } catch (x) {
+ (x = 1), (y = 2);
+ console.log(x);
+ }
+ console.log(x);
+ console.log(y);
+})();
+```
+
+- A: `1` `undefined` `2`
+- B: `undefined` `undefined` `undefined`
+- C: `1` `1` `2`
+- D: `1` `undefined` `undefined`
+
+Answer
+
+
+#### Answer: A
+
+The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
+
+Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+
+Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+
+
+
+
+---
+
+###### 39. Everything in JavaScript is either a...
+
+- A: primitive or object
+- B: function or object
+- C: trick question! only objects
+- D: number or object
+
+Answer
+
+
+#### Answer: A
+
+JavaScript only has primitive types and objects.
+
+Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+
+What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+
+
+
+
+---
+
+###### 40. What's the output?
+
+```javascript
+[[0, 1], [2, 3]].reduce(
+ (acc, cur) => {
+ return acc.concat(cur);
+ },
+ [1, 2]
+);
+```
+
+- A: `[0, 1, 2, 3, 1, 2]`
+- B: `[6, 1, 2]`
+- C: `[1, 2, 0, 1, 2, 3]`
+- D: `[1, 2, 6]`
+
+Answer
+
+
+#### Answer: C
+
+`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
+
+Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
+
+
+
+
+---
From 8897f31467f41775df06ae9697c73b099f68ef2f Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Thu, 27 Jun 2019 14:54:33 +0200
Subject: [PATCH 095/881] Question 22 edited
---
README_AR.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README_AR.md b/README_AR.md
index a1946e7e..cc12142b 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -694,9 +694,13 @@ const sum = eval("10*10+5");
sessionStorage.setItem("cool_secret", 123);
```
+
A - الى الأبد, فالبيانات لايمكن أن تفقد.
+
B - عندما يقوم المستخدم بقفل ال tab.
+
C - عندما يقوم المستخدم بقفل نافذه المتصفح , ليس فقط الtab.
+
D - عندما يقوم المستخدم بقفل جهاز الكمبيوتر.
From 6ab2f074914f71ee47e3cd939774dbb676bd9daf Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Thu, 27 Jun 2019 16:14:00 +0200
Subject: [PATCH 096/881] Questions 31 - 40 translated.
---
README_AR.md | 161 +++++++++++++++++++++++++++------------------------
1 file changed, 86 insertions(+), 75 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index cc12142b..98fa0b52 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -964,8 +964,9 @@ baz();
---
-
-###### 31. What is the event.target when clicking the button?
+
+31. ماهو ال event.target عندما نقوم بالضغط على الزر
+
```html
@@ -977,24 +978,31 @@ baz();
```
-- A: Outer `div`
-- B: Inner `div`
-- C: `button`
-- D: An array of all nested elements.
+
+- A: الخارجي `div`
-
Answer
-
+- B: الداخلي `div`
-#### Answer: C
+- C: `button`
-The deepest nested element that caused the event is the target of the event. You can stop bubbling by `event.stopPropagation`
+- D: array تحتوي على جميع العناصرالمتداخلة.
+
+الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+العنصر المتداخل الأعمق الذي تسبب بتنفيذ الevent هو العنصر الذي يستهدفه هذا الevent, بإمكانك إيقاف ال bubbling عن طريق `event.stopPropagation`.
+
---
-###### 32. When you click the paragraph, what's the logged output?
+
+32. عندما تقوم بالضغط على الفقرة (P), ماهو الناتج الذي ستتحصل عليه؟
+
```html
@@ -1009,19 +1017,19 @@ The deepest nested element that caused the event is the target of the event. You
- C: `p`
- D: `div`
-
Answer
+الإجابة
+
+الجواب هو الخيار الأول: A
-#### Answer: A
-
-If we click `p`, we see two logs: `p` and `div`. During event propagation, there are 3 phases: capturing, target, and bubbling. By default, event handlers are executed in the bubbling phase (unless you set `useCapture` to `true`). It goes from the deepest nested element outwards.
-
+إذا قمنا بالضغط على `p` سنرى إثنان من الlogs, ألا و هما `p` و `div`, أثناء عملية event propagation, هنالك ثلاث مراحل: الا وهي capturing, target و bubbling. بصورة افتراضية, الevent handlers يتم تنفيذهم في مرحلة الbubbling (إلا في حال أنك قمت بضبط قيمة `useCapture` ل `true` ). هي تتسلسل ابتداءا من أعمق عنصر متداخل تصاعدا الى الأقل عمقاً.
+
---
-###### 33. What's the output?
+33. ماهو الناتج؟
```javascript
const person = { name: "Lydia" };
@@ -1039,21 +1047,21 @@ sayHi.bind(person, 21);
- C: `Lydia is 21` `Lydia is 21`
- D: `Lydia is 21` `function`
-Answer
+الإجابة
+
+الجواب هو الخيار الرابع: D
-#### Answer: D
-
-With both, we can pass the object to which we want the `this` keyword to refer to. However, `.call` is also _executed immediately_!
-
-`.bind.` returns a _copy_ of the function, but with a bound context! It is not executed immediately.
+في الحالتين, بإمكاننا تمرير ال object الذي نود أن تشير اليه الكلمة المفتاحية `this`, ولكن, `.call` هي أيضا تم تنفيذها حالا.
+`.bind.` تقوم بإرجاع نسخة من الدالة, ولكن مع سياق محدد, لذا هي لا يتم تنفيذها حالاً.
+
---
-###### 34. What's the output?
+34. ماهو الناتج؟
```javascript
function sayHi() {
@@ -1068,20 +1076,21 @@ console.log(typeof sayHi());
- C: `"function"`
- D: `"undefined"`
-Answer
+الإجابة
+
+الجواب هو الخيار الثاني: B
-#### Answer: B
-
-The `sayHi` function returns the returned value of the immediately invoked function (IIFE). This function returned `0`, which is type `"number"`.
+دالة `sayHi` تقوم بإرجاع القيمة المرجعة من الدالة المناداة في اللحظة (IIFE). هذه الدالة تقوم بإرجاع `0`, و الذي نوعه عبارة عن `"number"`.
-FYI: there are only 7 built-in types: `null`, `undefined`, `boolean`, `number`, `string`, `object`, and `symbol`. `"function"` is not a type, since functions are objects, it's of type `"object"`.
+لمعلوماتك: لدينا فقط سبعة أنواع من ال built-in و هي : `null`, `undefined`, `boolean`, `number`, `string`, `object`, و `symbol`.`"function"` هي ليست نوع, وبما أن الدوال عبارة عن objects, ف هي ليست من النوع `"object"`.
+
---
-###### 35. Which of these values are falsy?
+35. أي هذه القيم هي قيم قابلة للخطأ؟
```javascript
0;
@@ -1095,14 +1104,14 @@ undefined;
- A: `0`, `''`, `undefined`
- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
- C: `0`, `''`, `new Boolean(false)`, `undefined`
-- D: All of them are falsy
+- D: جميعها
-Answer
+الإجابة
+
+الجواب هو الخيار الأول : A
-#### Answer: A
-
-There are only six falsy values:
+لدينا فقط ستة قيم قابلة للخطأ:
- `undefined`
- `null`
@@ -1111,14 +1120,15 @@ There are only six falsy values:
- `''` (empty string)
- `false`
-Function constructors, like `new Number` and `new Boolean` are truthy.
+Function constructors, مثل `new Number` و `new Boolean` هي قيم قابلة للصواب.
+
---
-###### 36. What's the output?
+36. ماهو الناتج؟
```javascript
console.log(typeof typeof 1);
@@ -1129,20 +1139,21 @@ console.log(typeof typeof 1);
- C: `"object"`
- D: `"undefined"`
-Answer
+الإجابة
+
+الجواب هو الخيار الثاني: B
-#### Answer: B
-
-`typeof 1` returns `"number"`.
-`typeof "number"` returns `"string"`
+`typeof 1` تقوم بإرجاع `"number"`.
+`typeof "number"` تقوم بإرجاع `"string"`
+
---
-###### 37. What's the output?
+37. ماهو الناتج؟
```javascript
const numbers = [1, 2, 3];
@@ -1155,23 +1166,23 @@ console.log(numbers);
- C: `[1, 2, 3, 7 x empty, 11]`
- D: `SyntaxError`
-Answer
+الإجابة
+
+الجواب هو الخيار الثالث: C
-#### Answer: C
-
-When you set a value to an element in an array that exceeds the length of the array, JavaScript creates something called "empty slots". These actually have the value of `undefined`, but you will see something like:
+عندما تقوم بضبط قيمة ما لعنصر في الarray , و بعد إضافة هذا العنصر انت تكون قد تجاوزت طول الarray, لغة الجافاسكريبت تنشيء شيئا يسمى ب "empty slots", أي خانة فارغة, و هي في الحقيقة تحمل القيمة `undefined`, و لكنك سترى شيئا كالتالي:
`[1, 2, 3, 7 x empty, 11]`
-depending on where you run it (it's different for every browser, node, etc.)
-
+وذلك يعتمد على المكان الذي قمت فيه بتشغيل البرنامج ( هو مختلف لكل متصفح, node, ...الخ)
+
---
-###### 38. What's the output?
+38. ماهو الناتج؟
```javascript
(() => {
@@ -1192,46 +1203,46 @@ depending on where you run it (it's different for every browser, node, etc.)
- C: `1` `1` `2`
- D: `1` `undefined` `undefined`
-Answer
+الإجابة
+
+الجواب هو الخيار الأول : A
-#### Answer: A
-
-The `catch` block receives the argument `x`. This is not the same `x` as the variable when we pass arguments. This variable `x` is block-scoped.
-
-Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.
+النطاق أو الblock `catch`يستقبل ال arguemnt الذي يساوي `x`, هذا ليس نفس القيمة `x` هندما قمنا بتمرير الarguments, هذا المتغير `x` هو متغير block-scoped, أي يتم التعامل معه أو مناداته فقط بداخل الblock الذي تم تعريفه به.
-Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
+لاحقا, قمنا بضبط القيمة `1` لهذا المتغير من نوع block-scoped, وقمنا أيضا بضبط قيمة للمتغير `y`. الآن نحن نقوم بطباعة قيمة المتغير الذي من نوع block-scoped و الذي هو `x` عن طريق الlog, و الذي هو يساوي `1`.
+بخارج نطاق ال`catch` block, `x` هي لاتزال `undefined`, و قيمة ال `y` تساوي `2`. عندما نريد طباعة قيمة ال x عن طريق الlog خارج نطاق ال `catch` block, فهي تقوم بإرجاع `undefined`, و ال `y` تقوم بإرجاع `2`.
+
---
-###### 39. Everything in JavaScript is either a...
+39. كل شيء في الجافاسكريبت هو عبارة عن ...
-- A: primitive or object
-- B: function or object
-- C: trick question! only objects
+- A: primitive أو object
+- B: function أو object
+- C: فقط objects , سؤال مخادع
- D: number or object
-Answer
+الإجابة
+
+الجواب هو الخيار الأول: A
-#### Answer: A
-
-JavaScript only has primitive types and objects.
-
-Primitive types are `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, and `symbol`.
+لغة الجافاسكريبت لديها فقط primitive types و objects.
-What differentiates a primitive from an object is that primitives do not have any properties or methods; however, you'll note that `'foo'.toUpperCase()` evaluates to `'FOO'` and does not result in a `TypeError`. This is because when you try to access a property or method on a primitive like a string, JavaScript will implicity wrap the object using one of the wrapper classes, i.e. `String`, and then immediately discard the wrapper after the expression evaluates. All primitives except for `null` and `undefined` exhibit this behaviour.
+نقصد بال Primitive types: `boolean`, `null`, `undefined`, `bigint`, `number`, `string`, و `symbol`.
+مايميز ال primitive من ال object هو أن ال primitives ليس لديها أي خصائص أو methods; ولكنك ستلاحظ أن `'foo'.toUpperCase()`يتم تقييمها ومعالجتها الى `'FOO'`و لا نتحصل على الخطأ `TypeError`. هذا لأنه عندما تحاول الوصول الى خاصية أو method لمتغير من من نوع primitive مثل ال string, فإن لغة الجافاسكريبت ستقوم بشكل ضمني بعمل wrap لل object بإستخدام واحدة من ال wrapper Classes, أي مانعنيه `String`, و لاحقا بصورة مباشرة يقوم بالتخلص من الwrapper, بعد أن يتم تقييم و تنفيذ الexpression. جميع الprimitives, ماعدا `null` و `undefined` تقوم بعمل هذه العملية.
+
---
-###### 40. What's the output?
+40. ماهو الناتج؟
```javascript
[[0, 1], [2, 3]].reduce(
@@ -1247,16 +1258,16 @@ What differentiates a primitive from an object is that primitives do not have an
- C: `[1, 2, 0, 1, 2, 3]`
- D: `[1, 2, 6]`
-Answer
+الإجابة
+
+الجواب هو الخيارالثالث: C
-#### Answer: C
-
-`[1, 2]` is our initial value. This is the value we start with, and the value of the very first `acc`. During the first round, `acc` is `[1,2]`, and `cur` is `[0, 1]`. We concatenate them, which results in `[1, 2, 0, 1]`.
-
-Then, `[1, 2, 0, 1]` is `acc` and `[2, 3]` is `cur`. We concatenate them, and get `[1, 2, 0, 1, 2, 3]`
+`[1, 2]` هي القيمة المبدئية.هذه القيمة هي التي بدأنا بها, و هي القيمة الأولى ل `acc`. أثناء الدورة الأولى`acc` تساوي `[1,2]` و `cur` تساوي `[0, 1]`, عندما نقوم بدمجهما سويا عن طريق concat يصبح لدينا الناتج `[1, 2, 0, 1]`.
+إذاً, `[1, 2, 0, 1]` هي `acc` و `[2, 3]` هي `cur`. نقوم بدمجهما سويةو نتحصل على `[1, 2, 0, 1, 2, 3]`.
+
---
From 5f7e35baab94c2151faf23d3c8ecb8984e573803 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Thu, 27 Jun 2019 16:17:28 +0200
Subject: [PATCH 097/881] Update README_AR.md
---
README_AR.md | 5 -----
1 file changed, 5 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index 98fa0b52..b4b9e260 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -978,15 +978,10 @@ baz();
```
-
- A: الخارجي `div`
-
- B: الداخلي `div`
-
- C: `button`
-
- D: array تحتوي على جميع العناصرالمتداخلة.
-
الإجابة
From 3d98f9f1e82c83572a5adc95afbd882ff7a51daf Mon Sep 17 00:00:00 2001
From: kimdanah
Date: Fri, 28 Jun 2019 06:53:13 +0900
Subject: [PATCH 098/881] Translate the questions 44-52 to Korean. Done.
---
README-ko_KR.md | 188 ++++++++++++++++++++++++------------------------
1 file changed, 93 insertions(+), 95 deletions(-)
diff --git a/README-ko_KR.md b/README-ko_KR.md
index a30ea659..7719f3c2 100644
--- a/README-ko_KR.md
+++ b/README-ko_KR.md
@@ -42,9 +42,9 @@ sayHi();
#### 정답: D
-함수내에서, 우선 `var`키워드를 사용해 `name`변수를 선언해요. 이것은 변수가 정의되어 있는 행에 실제로 도달할 때까지, 변수는 `undefined`을 기본값으로 호이스팅 되(생성단계에 메모리 공간이 설정됨)는 것을 의미해요. `name` 변수를 출력 하려는 줄에서 아직 변수를 정의하고 있지 않기 때문에, `undefined`값을 유지하고 있어요.
+함수 내에서, 우선 `var`키워드를 사용해 `name`변수를 선언해요. 이것은 변수가 정의되어 있는 행에 실제로 도달할 때까지, 변수는 `undefined`의 기본값으로 호이스팅 되(생성단계에 메모리 공간이 설정됨)는 것을 의미해요. `name` 변수를 출력하려는 줄에서 아직 변수를 정의하고 있지 않기 때문에, `undefined`값을 유지하고 있어요.
-`let`키워드(그리고 `const`)를 가지는 변수들은, `var`와는 달리, 호이스팅되지만 초기화되지 않아요. 그것들을 선언(초기화)하는 줄 전에는 접근 할 수 없어요. 이것은 "일시적 사각지대"라고 불려요. 선언되기 전에 변수에 접근하려고 하면, JavaScript는 `ReferenceError`를 던져요.
+`let`키워드(그리고 `const`)를 가지는 변수들은, `var`와는 달리, 호이스팅되지만 초기화되지 않아요. 그것들을 선언(초기화)하는 줄 전에는 접근할 수 없어요. 이것은 "일시적 사각지대"라고 불려요. 선언되기 전에 변수에 접근하려고 하면, JavaScript는 `ReferenceError`를 던져요.
@@ -72,9 +72,9 @@ for (let i = 0; i < 3; i++) {
#### 정답: C
-JavaScript의 이벤트 큐 때문에, `setTimeout`의 콜백함수는 루프가 실행된 _후에_ 호출되요. 첫번째의 루프 변수 `i`는 `var`키워드를 사용해 선언되어 있으므로, 이 값은 전역변수가 되요. 루프 동안, 단항 연산자 `++`를 사용하여, 매번 `i`의 값을 `1`씩 증가했어요. `setTimeout`콜백 함수가 호출되기까지, 첫번째 예에서 `i`는 `3`과 같아요.
+JavaScript의 이벤트 큐 때문에, `setTimeout`의 콜백 함수는 루프가 실행된 _후에_ 호출되어요. 첫 번째의 루프 변수 `i`는 `var`키워드를 사용해 선언되어 있으므로, 이 값은 전역 변수가 되어요. 루프 동안, 단항 연산자 `++`를 사용하여, 매번 `i`의 값을 `1`씩 증가했어요. `setTimeout`콜백 함수가 호출되기까지, 첫 번째 예에서 `i`는 `3`과 같아요.
-두번째 루프에서, 변수 `i`는 `let`키워드를 사용해 선언되었어요: `let` (그리고 `const`)키워드로 선언된 변수는 블록 범위에요(블록은 `{ }` 사이의 모든것). 각각의 반복동안, `i`는 새로운 값을 가지고, 각각의 값은 루프 안쪽 범위에 있어요.
+두 번째 루프에서, 변수 `i`는 `let`키워드를 사용해 선언되었어요: `let`(그리고 `const`)키워드로 선언된 변수는 블록 범위예요(블록은 `{ }` 사이의 모든 것). 각각의 반복 동안, `i`는 새로운 값을 가지고, 각각의 값은 루프 안쪽 범위에 있어요.
@@ -106,11 +106,11 @@ shape.perimeter();
#### 정답: B
-`diameter`의 값은 정규 함수인 반면, `perimeter`의 값은 화살표 함수라는 점에 유의해요.
+`diameter`의 값은 정규 함수인 반면, `perimeter`의 값은 화살표 함수라는 점을 유의하세요.
화살표 함수에서는, 통상적인 함수와는 달리, `this`키워드는 현재 주위의 범위를 참조해요! 이것은 `perimeter`를 부르면, shape 객체가 아닌, 그 주위의 범위(예를 들면 window)를 참조하는 것을 의미해요.
-그 객체에는 `radius`라는 값은 없고, `undefined`를 리턴해요.
+그 객체에는 `radius`라는 값은 없어, `undefined`를 리턴해요.
@@ -135,7 +135,7 @@ shape.perimeter();
단항 더하기는 피연산자를 숫자로 변환하려 해요. `true`는 `1`, `false`은 `0`.
-문자열 `'Lydia'`는 참 같은 값이에요. 실제로 묻고 있는 것은, "이 참 같은 값이 거짓 같은 값인가?"에요. 이것은 `false`을 리턴해요.
+문자열 `'Lydia'`는 참 같은 값이에요. 실제로 물어보는 것은, "이 참 같은 값이 거짓 같은 값인가?"에요. 이것은 `false`을 리턴해요.
@@ -165,15 +165,15 @@ const mouse = {
#### 정답: A
-JavaScript에서, 모든 객체 키는 문자열이에요 (Symbol이 아닌 한). 비록 그것을 문자열 _형_ 으로 입력하지 않아도, 항상 내부적으로 문자열로 변환되요.
+JavaScript에서, 모든 객체 키는 문자열이에요 (심볼이 아닌 한). 비록 그것을 문자열 _형_ 으로 입력하지 않아도, 항상 내부적으로 문자열로 변환되어요.
-JavaScript는 문장을 해석(또는 박스해제)해요. 대괄호 표기를 사용하면, 첫 번째 좌대괄호 `[`를 보고 오른쪽 대괄호 `]`를 찾을 때까지 진행해요. 그때, 그 문장을 평가할거에요.
+JavaScript는 문장을 해석(또는 박스 해제)해요. 대괄호 표기를 사용하면, 첫 번째 왼쪽 대괄호 `[`를 보고 오른쪽 대괄호 `]`를 찾을 때까지 진행해요. 그때, 그 문장을 평가할 거에요.
`mouse[bird.size]`: 먼저 `bird.size`를 평가해요, 이것은 `"small"`이에요. `mouse["small"]` 은 `true`를 리턴해요.
그러나, 닷 표기에서는, 이것은 발생하지 않아요, `mouse`는 `bird`라고 불리는 키를 가지고 있지 않아요 즉, `mouse.bird`는 `undefined`를 의미해요.
-또, 닷 표기를 사용해 `size`를 물어봐요. `mouse.bird.size`. `mouse.bird`는 `undefined`로, 실제로는 `undefined.size`를 물어보고 있어요. 이것은 유효하지 않기 때문에, `Cannot read property "size" of undefined`와 비슷한 에러를 던질거에요.
+또, 닷 표기를 사용해 `size`를 물어봐요. `mouse.bird.size`. `mouse.bird`는 `undefined`로, 실제로는 `undefined.size`를 물어보고 있어요. 이것은 유효하지 않기 때문에, `Cannot read property "size" of undefined`와 비슷한 에러를 던질 거예요.
@@ -208,7 +208,7 @@ JavaScript에서, 모든 객체는 서로 동일하게 설정하면 _참조_ 에
-한개의 객체를 변경하면, 그것들 모두 변경해요.
+한 개의 객체를 변경하면, 그것들 모두 변경해요.
@@ -237,11 +237,11 @@ console.log(b === c);
#### 정답: C
-`new Number()`는, 내장 함수 생성자에요. 숫자처럼 보이지만, 실제로는 숫자가 아니에요: 많은 추가 특성이 있고 그것은 객체에요.
+`new Number()`는, 내장 함수 생성자예요. 숫자처럼 보이지만, 실제로는 숫자가 아니에요: 많은 추가 특성이 있고 그것은 객체예요.
`==`연산자를 사용할 때, 그건 같은 _값_ 을 가지고 있는지 여부만 확인해요. 그것들은 모두`3`의 값을 가지고 있으므로, `true`를 리턴해요.
-그러나, `===`연산자를 사용할 때, 값 _과_ 형 둘다 같아야 해요. 이건 아니에요: `new Number()`는 숫자가 아니에요. **객체**에요. 그래서 둘다 `false`를 리턴해요.
+그러나, `===`연산자를 사용할 때, 값 _과_ 형 둘 다 같아야 해요. 이건 아니에요: `new Number()`는 숫자가 아니에요. **객체**에요. 그래서 둘 다 `false`를 리턴해요.
@@ -276,7 +276,7 @@ console.log(freddie.colorChange("orange"));
#### 정답: D
-`colorChange`함수는 정적이에요. 정적 메소드는 그것들이 만들어지는 생성자 상에서만 살아있도록 설계되어 있어, 어떤 자식들도 상속 받을 수 없어요. `freddie`는 자식이기 때문에, 이 함수는 상속되지 않고, `freddie`인스턴스에서는 이용할 수 없어요: `TypeError`가 던져져요.
+`colorChange`함수는 정적이에요. 정적 메소드는 그것들이 만들어지는 생성자 상에서만 살아있도록 설계되어 있어, 어떤 자식들도 상속받을 수 없어요. `freddie`는 자식이기 때문에, 이 함수는 상속되지 않고, `freddie`인스턴스에서는 이용할 수 없어요: `TypeError`가 던져져요.
@@ -300,7 +300,7 @@ console.log(greetign);
#### 정답: A
-객체는 출력되요, 전역객체에 빈 객체를 방금 만들었기 때문이에요. `greeting`을 `greettign`으로 잘못 입력했을 경우, JS 인터프리터는 실제로 이것을 `global.greettign = {}` (또는 브라우저의 `window.greetign = {}`) 라고 간주해요.
+객체는 출력돼요, 전역 객체에 빈 객체를 방금 만들었기 때문이에요. `greeting`을 `greettign`으로 잘못 입력했을 경우, JS 인터프리터는 실제로 이것을 `global.greettign = {}` (또는 브라우저의 `window.greetign = {}`) 라고 간주해요.
이것을 피하기 위해서, `"use strict"`를 사용할 수 있어요. 이렇게 하면 변수를 어떤 것과 동일하게 설정하기 전에 변수를 선언했는지 확인할 수 있어요.
@@ -332,7 +332,7 @@ bark.animal = "dog";
JavaScript에서는 가능해요, 함수는 객체이기 때문이에요!
(윈시형 이외는 모두 객체)
-함수는 특별한 종류의 객체에요. 당신이 쓴 코드는 실제 함수가 아니에요. 함수는 속성을 가진 객체에요. 이 속성은 호출이 가능해요.
+함수는 특별한 종류의 객체예요. 당신이 쓴 코드는 실제 함수가 아니에요. 함수는 속성을 가진 객체예요. 이 속성은 호출이 가능해요.
@@ -373,7 +373,7 @@ Person.prototype.getFullName = function() {
};
```
-`member.getFullName()`은 작동되요. 이것은 왜 유익할까요? 이 메소드를 생성자 자체에 추가했다고 할게요. 아마도 모든 `Person` 인스턴스는 이 메소드를 필요로 하지 않을 수도 있어요. 그 경우 그들은 아직 속성을 갖고, 각각의 인스턴스를 위해 메모리 공간을 소비하기 때문에, 많은 메모리 공간을 낭비하게 되요. 대신에, 프로토타입을 추가하는 것만으로, 메모리의 한 지점을 가지지만, 모든 것들은 그것에 접근 할 수 있어요.
+`member.getFullName()`은 작동해요. 이것은 왜 유익할까요? 이 메소드를 생성자 자체에 추가했다고 할게요. 아마도 모든 `Person` 인스턴스는 이 메소드를 필요로 하지 않을 수도 있어요. 그 경우 그들은 아직 속성을 갖고, 각각의 인스턴스를 위해 메모리 공간을 소비하기 때문에, 많은 메모리 공간을 낭비해요. 대신에, 프로토타입을 추가하는 것만으로, 메모리의 한 지점을 가지지만, 모든 것들은 그것에 접근 할 수 있어요.
@@ -405,9 +405,9 @@ console.log(sarah);
#### 정답: A
-`sarah`를 위해, `new`키워드를 사용하지 않았어요. `new`를 사용한 경우, 이것은 우리가 만든 새로운 빈 객체를 참조해요. 그러나, `new`를 추가하지 않으면 **전역변수**를 참조하게 되요!
+`sarah`를 위해, `new`키워드를 사용하지 않았어요. `new`를 사용한 경우, 이것은 우리가 만든 새로운 빈 객체를 참조해요. 그러나, `new`를 추가하지 않으면 **전역변수**를 참조해요!
-`this.firstName`에 `"Sarah"`을 대입하고, `this.lastName`에 `"Smith"`을 대입 했다고 말했었어요. (그렇지만) 우리는 실제로, `global.firstName = 'Sarah'` 그리고 `global.lastName = 'Smith'`를 정의한거에요. `sarah` 자체는 `undefined`로 남아있어요.
+`this.firstName`에 `"Sarah"`을 대입하고, `this.lastName`에 `"Smith"`을 대입했다고 말했었어요. (그렇지만) 우리는 실제로, `global.firstName = 'Sarah'` 그리고 `global.lastName = 'Smith'`를 정의해요. `sarah` 자체는 `undefined`로 남아있어요.
@@ -426,7 +426,7 @@ console.log(sarah);
#### 정답: D
-**capturing** 단계 동안에, 이벤트는 조상요소를 거쳐 목표 요소까지 내려가요. 그런 다음 **target** 요소에 도달하고, **bubbling**이 시작되요.
+**capturing** 단계 동안에, 이벤트는 조상요소를 거쳐 목표 요소까지 내려가요. 그런 다음 **target** 요소에 도달하고, **bubbling**이 시작돼요.
@@ -445,7 +445,7 @@ console.log(sarah);
#### 정답: B
-**기본객체**를 제외한, 모든 객체는 프로포타입을 가져요. 기본객체는 사용자에 의해 만들어지거나 `new`키워드를 사용하여 만들어져요. 기본객체는 `.toString`와 같은 몇개의 메소드와 속성에 접근할 수 있어요. 이것이 내장 JavaScript 메소드를 사용할 수 있는 이유죠! 이러한 모든 메소드는 프로토 타입에서 이용 할 수 있어요. JavaScript가 당신의 객체를 직접 찾을 수 없더라도, 당신이 접근 할 수 있도록, 프로토타입 체인으로 내려가서 찾을거에요.
+**기본 객체**를 제외한, 모든 객체는 프로토타입을 가져요. 기본 객체는 사용자에 의해 만들어지거나 `new`키워드를 사용하여 만들어져요. 기본 객체는 `.toString`와 같은 몇 개의 메소드와 속성에 접근할 수 있어요. 이것이 내장 JavaScript 메소드를 사용할 수 있는 이유죠! 이러한 모든 메소드는 프로토 타입에서 이용할 수 있어요. JavaScript가 당신의 객체를 직접 찾을 수 없더라도, 당신이 접근할 수 있도록, 프로토타입 체인으로 내려가서 찾을거에요.
@@ -472,9 +472,9 @@ sum(1, "2");
#### 정답: C
-JavaScript는 **동적으로 만들어진 언어**에요: 특정변수가 어떤 형인지 지정하지 않아요. 변수는 당신이 모르는 사이에 자동으로 다른 형으로 변환 될 수 있는데, 이걸 _암묵적 형 변환_ 이라고 불러요. **Coercion**은 하나의 형을 다른 형으로 변환하는 거에요.
+JavaScript는 **동적으로 만들어진 언어**에요: 특정 변수가 어떤 형인지 지정하지 않아요. 변수는 당신이 모르는 사이에 자동으로 다른 형으로 변환될 수 있는데, 이걸 _암묵적 형 변환_ 이라고 불러요. **Coercion**은 하나의 형을 다른 형으로 변환해요.
-이 예제에서, 함수가 이해하고 값을 리턴하도록, JavaScript는 숫자 `1`을 문자열로 변환해요. 수형 (`1`)와 문자열형 (`'2'`)의 추가 중에는, 숫자는 문자열로 취급되요. `"Hello" + "World"`처럼 문자열을 연결할 수 있어요, 따라서 여기 `"1" + "2"`는 `"12"`을 리턴하는 일이 발생해요.
+이 예제에서, 함수가 이해하고 값을 리턴하도록, JavaScript는 숫자 `1`을 문자열로 변환해요. 수형 (`1`)와 문자열형 (`'2'`)의 추가 중에는, 숫자는 문자열로 취급해요. `"Hello" + "World"`처럼 문자열을 연결할 수 있어요, 따라서 여기 `"1" + "2"`는 `"12"`을 리턴하는 일이 발생해요.
@@ -500,12 +500,12 @@ console.log(number);
#### 정답: C
-**접미사** 단항연산자 `++`:
+**접미사** 단항 연산자 `++`:
1. 값 리턴 (이것은 `0`을 리턴해요)
2. 값 증가 (number는 지금 `1`이에요)
-**접두사** 단항연산자 `++`:
+**접두사** 단항 연산자 `++`:
1. 값 증가 (number는 지금 `2`이에요)
2. 값 리턴 (이것은 `2`을 리턴해요)
@@ -541,7 +541,7 @@ getPersonInfo`${person} is ${age} years old`;
#### 정답: B
-태그드 템플릿 리터럴을 사용하는 경우, 첫번재 인수의 값은 항상 문자열 값의 배열이에요. 나머지 인수는 식을 통과한 값을 얻게 되요.
+태그드 템플릿 리터럴을 사용하는 경우, 첫 번재 인수의 값은 항상 문자열 값의 배열이에요. 나머지 인수는 식을 통과한 값을 얻어요.
@@ -573,11 +573,11 @@ checkAge({ age: 18 });
#### 정답: C
-동등성을 테스트할 때, 원시형은 그 _값_ 에 따라 비교되며, 객체는 그들의 _참조_ 에 따라 비교되요. JavaScript 객체가 메모리내의 같은 장소를 참조하고 있는지 여부를 확인해요.
+동등성을 테스트할 때, 원시형은 그 _값_ 에 따라 비교되며, 객체는 그들의 _참조_ 에 따라 비교돼요. JavaScript 객체가 메모리 내의 같은 장소를 참조하고 있는지 여부를 확인해요.
비교하고 있는 두개의 객체는 그것이 없어요: 파라미터로 전달된 객체와 동등성을 확인하기 위해 사용한 객체는 메모리 내의 다른 장소를 참조해요.
-이것이 `{ age: 18 } === { age: 18 }` 그리고 `{ age: 18 } == { age: 18 }` 두개 다 `false`를 리턴하는 이유죠.
+이것이 `{ age: 18 } === { age: 18 }` 그리고 `{ age: 18 } == { age: 18 }` 두 개 다 `false`를 리턴하는 이유죠.
@@ -633,7 +633,7 @@ getAge();
#### 정답: C
-`"use strict"`을 사용하면, 실수로 전역 변수를 선언하지 않게 할 수 있어요. `age`이라는 변수를 선언한적이 전혀없고, `"use strict"`을 사용하고 있으므로, 참조 에러를 던지게 될거에요. 만약 `"use strict"`을 사용하지 않았다면, 이건 작동할거에요, `age` 속성이 전역 객체에 추가된 것이기 때문이죠.
+`"use strict"`을 사용하면, 실수로 전역 변수를 선언하지 않게 할 수 있어요. `age`이라는 변수를 선언한 적이 전혀 없고, `"use strict"`을 사용하고 있으므로, 참조 에러를 던지게 될 거에요. 만약 `"use strict"`을 사용하지 않았다면, 이건 작동할 거에요, `age` 속성이 전역 객체에 추가된 것이기 때문이죠.
@@ -656,7 +656,7 @@ const sum = eval("10*10+5");
#### 정답: A
-`eval` 문자열로서 통과된 코드를 평가해요. 이 경우와 같이 만약 그것이 표현식이라면, 표현식을 평가해요. 표현식은 `10 * 10 + 5` 이에요. 이것은 숫자 `105`를 리턴해요.
+`eval` 문자열로서 통과된 코드를 평가해요. 이 경우와 같이 만약 그것이 표현식이라면, 표현식을 평가해요. 표현식은 `10 * 10 + 5`이에요. 이것은 숫자 `105`를 리턴해요.
@@ -679,9 +679,9 @@ sessionStorage.setItem("cool_secret", 123);
#### 정답: B
-`sessionStorage`에 저장된 데이터는 _탭_ 을 닫은 후에 삭제되요.
+`sessionStorage`에 저장된 데이터는 _탭_ 을 닫은 후에 삭제돼요.
-만약 `localStorage`를 사용했다면, 예를들어 `localStorage.clear()`를 호출 하지 않는 한, 데이터는 영원할거에요.
+만약 `localStorage`를 사용했다면, 예를 들어 `localStorage.clear()`를 호출하지 않는 한, 데이터는 영원할 거에요.
@@ -707,7 +707,7 @@ console.log(num);
#### 정답: B
-`var`키워드를 사용하면, 같은 이름으로 복수의 변수를 선언 할 수 있어요. 변수는 최신의 값을 유지해요.
+`var`키워드를 사용하면, 같은 이름으로 복수의 변수를 선언할 수 있어요. 변수는 최신의 값을 유지해요.
블록 스코프의 `let` 또는 `const`에서는 할 수 없어요.
@@ -738,7 +738,7 @@ set.has(1);
#### 정답: C
-모든 객체 키는(Symbol 제외) 문자열로 직접 입력하지 않아도, 내부적으로는 문자열이에요. 이것이 `obj.hasOwnProperty('1')` 또한 true를 리턴하는 이유에요.
+모든 객체 키는(심볼 제외) 문자열로 직접 입력하지 않아도, 내부적으로는 문자열이에요. 이것이 `obj.hasOwnProperty('1')` 또한 true를 리턴하는 이유죠.
set에서는 작동하지 않아요. set에는 `'1'`이 없어요: `set.has('1')`는 `false`를 리턴해요. 그것은 수형인 `1`을 가지고 있어, `set.has(1)`은 `true`를 리턴해요.
@@ -764,7 +764,7 @@ console.log(obj);
#### 정답: C
-같은 이름의 키를 두개 가지고 있다면, 첫번째 위치에서, 마지막에 지정된 값으로 대체 될 거에요.
+같은 이름의 키를 두 개 가지고 있다면, 첫 번째 위치에서, 마지막에 지정된 값으로 대체될 거예요.
@@ -782,7 +782,7 @@ console.log(obj);
#### 정답: A
-기본적인 execution context는 전역 실행 문장이에요: 당신의 코드 모든 곳에서 접근 할 수 있어요.
+기본적인 execution context는 전역 실행 문장이에요: 당신의 코드 모든 곳에서 접근할 수 있어요.
@@ -808,7 +808,7 @@ for (let i = 1; i < 5; i++) {
#### 정답: C
-`continue` 표현식은 특정 조건이 `true`를 리턴하면 반복처리를 건너뛰어요.
+`continue` 표현식은 특정 조건이 `true`를 리턴하면 반복 처리를 건너뛰어요.
@@ -837,7 +837,7 @@ name.giveLydiaPizza();
#### 정답: A
-`String`은 내장 생성자로 속성을 추가 할 수 있어요. 단지 프로토타입이라는 메소드를 추가했어요. 원시형 문자열은 문자열 프로토타입 함수에 의해 생성된 문자열 객체로 자동 변환되요. 그래서, 모든 문자열(문자열 객체)는 그 메소드에 접근 할 수 있어요!
+`String`은 내장 생성자로 속성을 추가할 수 있어요. 단지 프로토타입이라는 메소드를 추가했어요. 원시형 문자열은 문자열 프로토타입 함수에 의해 생성된 문자열 객체로 자동 변환돼요. 그래서, 모든 문자열(문자열 객체)는 그 메소드에 접근할 수 있어요!
@@ -867,11 +867,11 @@ console.log(a[b]);
#### 정답: B
-객체 키는 자동으로 문자열로 변환되요. 객체 `a`의 키 값으로 `123`를 세팅하려고 해요.
+객체 키는 자동으로 문자열로 변환돼요. 객체 `a`의 키 값으로 `123`를 세팅하려고 해요.
-그러나, 객체를 문자열화 하면 `"[Object object]"`가 되요. 그래서 여기서 밀하고자 하는 건 `a["Object object"] = 123` 이라는 거에요. 그후, 같은 일을 다시 시도해요. `c`는 암묵적으로 문자열화 한 다른객체에요. 그래서 `a["Object object"] = 456`이 되요.
+그러나, 객체를 문자열화 하면 `"[Object object]"`가 돼요. 그래서 여기서 말하고자 하는 건 `a["Object object"] = 123`이라는 거예요. 그 후, 같은 일을 다시 시도해요. `c`는 암묵적으로 문자열화 한 다른 객체에요. 그래서 `a["Object object"] = 456`이 돼요.
-그후, `a[b]`는 출력하면 실제로는 `a["Object object"]`에요. 단지 `456`를 설정 했기때문에, `456`를 리턴해요.
+그 후, `a[b]`는 출력하면 실제로는 `a["Object object"]`에요. 단지 `456`를 설정했기 때문에, `456`를 리턴해요.
@@ -900,33 +900,31 @@ baz();
#### 정답: B
-`setTimeout`함수를 처음으로 호출 했어요. 그러나 그것은 마지막에 출력되요.
+처음에 `setTimeout`함수를 호출했어요. 그러나 그것은 마지막에 출력돼요.
-브라우저에는 런타임 엔진 뿐만 아니라 `WebAPI`라고 불리는 것도 있기 때문이에요. `WebAPI`는 `setTimeout`함수를 최초에 부여하는데, DOM을 예로 들 수 있어요.
-
-After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
+브라우저에는 런타임 엔진뿐만 아니라 `WebAPI`라고 불리는 것도 있기 때문이에요. `WebAPI`는 `setTimeout`함수를 최초에 부여하는데, DOM을 예로 들 수 있어요.
_callback_ 이 WebAPI에 푸시된 후, `setTimeout`함수 자체(callback이 아니에요!)는 stack에 사라졌어요.
-지금, `foo` 는 호출 되었고, `"First"`는 출력 되었어요.
+지금, `foo` 는 호출되었고, `"First"`는 출력되었어요.
-`foo`는 stack에 사라지고, `baz`가 호출 되었어요. `"Third"`가 출력 되었어요.
+`foo`는 stack에 사라지고, `baz`가 호출되었어요. `"Third"`가 출력되었어요.
-WebAPI는 준비가 될때 마다 stack에 항목을 추가 할 수 없어요. 대신에, _queue_ 라고 불리는 것에 callback함수를 푸시해요.
+WebAPI는 준비가 될 때마다 stack에 항목을 추가할 수 없어요. 대신에, _queue_ 라고 불리는 것에 callback함수를 푸시해요.
-여기서 event loop가 작동하기 시작해요. **event loop**는 stack과 task queue를 봐요. stack이 비어있다면, queue에 첫번째것을 가져다가 stack 위로 푸시해요.
+여기서 event loop가 작동하기 시작해요. **event loop**는 stack과 task queue를 봐요. stack이 비어있다면, queue에 첫 번째의 것을 가져다가 stack 위로 푸시해요.
-`bar`가 호출되었고, `"Second"`가 출력 되었으며, stack에서 사라졌어요.
+`bar`가 호출되었고, `"Second"`가 출력되었으며, stack에서 사라졌어요.
@@ -955,7 +953,7 @@ WebAPI는 준비가 될때 마다 stack에 항목을 추가 할 수 없어요.
#### 정답: C
-가장 깊이 중첩된 요소가 이벤트를 발생시킬 이벤트 대상이에요. `event.stopPropagation`을 통해서 버블링을 중단 할 수 있어요.
+가장 깊이 중첩된 요소가 이벤트를 발생시킬 이벤트 대상이에요. `event.stopPropagation`을 통해서 버블링을 중단할 수 있어요.
@@ -982,7 +980,7 @@ WebAPI는 준비가 될때 마다 stack에 항목을 추가 할 수 없어요.
#### 정답: A
-`p`를 클릭하면, 2개의 로그를 볼 수 있어요: `p` 그리고 `div`. 이벤트의 전파 중에는 3 단계가 있어요: 캡처링, 타켓, 버블링. 기본적으로, 이벤트 핸들러는 버블링단계에서 시작되요. (`useCapture`를 `true`로 설정하지 않는 한). 가장 깊게 중첩된 요소로 부터 바깥쪽으로 나가요.
+`p`를 클릭하면, 2개의 로그를 볼 수 있어요: `p` 그리고 `div`. 이벤트의 전파 중에는 3 단계가 있어요: 캡처링, 타겟, 버블링. 기본적으로, 이벤트 핸들러는 버블링 단계에서 시작돼요. (`useCapture`를 `true`로 설정하지 않는 한). 가장 깊게 중첩된 요소로부터 바깥쪽으로 나가요.
@@ -1012,9 +1010,9 @@ sayHi.bind(person, 21);
#### 정답: D
-두개 모두, `this`키워드를 참조하고자하는 객체로 보낼 수 있어요. 그러나, `.call`은 _즉시 실행되요_!
+두 개 모두, `this`키워드를 참조하고자 하는 객체로 보낼 수 있어요. 그러나, `.call`은 _즉시 실행돼요_!
-`.bind.`는 함수의 _복사본_ 을 리턴하지만, 바인딩 컨텍스트에요! 이건 즉시 실행되지 않아요.
+`.bind.`는 함수의 _복사본_ 을 리턴하지만, 바인딩 콘텍스트죠! 이건 즉시 실행되지 않아요.
@@ -1043,7 +1041,7 @@ console.log(typeof sayHi());
`sayHi`함수는 즉시 호출 함수(IIFE)로서 리턴된 값을 리턴해요. 이 함수는 `0`을 리턴하고, 형은 `"number"`이에요.
-참고: 단 7개의 내장형이 있어요: `null`, `undefined`, `boolean`, `number`, `string`, `object` 그리고 `symbol`. `"function"`은 객체이기 때문에 형이아니라 `"object"` 형이에요.
+참고: 단 7개의 내장형이 있어요: `null`, `undefined`, `boolean`, `number`, `string`, `object` 그리고 `symbol`. `"function"`은 객체이기 때문에 형이 아니라 `"object"` 형이에요.
@@ -1071,7 +1069,7 @@ undefined;
#### 정답: A
-단 6개의 거짓 값이 있어요:
+단 6개의 거짓 같은 값이 있어요:
- `undefined`
- `null`
@@ -1080,7 +1078,7 @@ undefined;
- `''` (빈 문자열)
- `false`
-`new Number` 그리고 `new Boolean`와 같은 생성자 함수는 참같은 값이에요.
+`new Number` 그리고 `new Boolean`와 같은 생성자 함수는 참 같은 값이에요.
@@ -1129,12 +1127,12 @@ console.log(numbers);
#### 정답: C
-배열의 길이를 초과한 값을 배열의 요소로 설정하고자 할때, JavaScript는 "empty slots"이라고 불리는 것을 생성해요. 이것은 실제로 `undefined`의 값을 가지고 있지만, 다음과 같은 것을 보게 될거에요:
+배열의 길이를 초과한 값을 배열의 요소로 설정하고자 할 때, JavaScript는 "empty slots"이라고 불리는 것을 생성해요. 이것은 실제로 `undefined`의 값을 가지고 있지만, 다음과 같은 것을 보게 될 거에요:
`[1, 2, 3, 7 x empty, 11]`
depending on where you run it (it's different for every browser, node, etc.)
-실행 위치에 따라 달라요 (브라우저, node 등 마다 달라요.)
+실행 위치에 따라 달라요 (브라우저, node 등마다 달라요.)
@@ -1167,7 +1165,7 @@ depending on where you run it (it's different for every browser, node, etc.)
#### 정답: A
-`catch`블록은 `x`의 인자를 받아요. 이것은 인수를 전달할때 변수로서의 `x`와는 달라요. 이 `x` 변수는 블록-스코프에요.
+`catch`블록은 `x`의 인수를 받아요. 이것은 인수를 전달할 때 변수로서의 `x`와는 달라요. 이 `x` 변수는 블록-스코프예요.
후에, 블록-스코프 변수는 `1`로 설정하고, 변수 `y`의 값을 설정해요. 여기서, 블록-스코프의 변수 `x`를 출력하는데, 이것은 `1`이에요.
@@ -1194,7 +1192,7 @@ JavaScript는 원시형과 객체만 가지고 있어요.
원시형은 `boolean`, `null`, `undefined`, `bigint`, `number`, `string` 그리고 `symbol`이 있어요.
-원시형과 객체를 구별하는 법은 원시형에는 속성이나 메소드가 없어요. 그러나 `'foo'.toUpperCase()`는 `'FOO'`로 평가되어, `TypeError`의 결과가 되지 않아요. 문자열과 같은 원시형이 속성 또는 메소드에 접근하려고 할때, JavaScript는 래퍼 클래스 중 하나인 `String`을 사용하여 암묵적으로 감싸고, 표현식이 평가된 후 즉시 래퍼를 폐기하기 때문이에요. `null` 그리고 `undefined`를 제외한 모든 원시형은 이러한 행동을 합니다.
+원시형과 객체를 구별하는 법은 원시형에는 속성이나 메소드가 없어요. 그러나 `'foo'.toUpperCase()`는 `'FOO'`로 평가되어, `TypeError`의 결과가 되지 않아요. 문자열과 같은 원시형이 속성 또는 메소드에 접근하려고 할 때, JavaScript는 래퍼 클래스 중 하나인 `String`을 사용하여 암묵적으로 감싸고, 표현식이 평가된 후 즉시 래퍼를 폐기하기 때문이에요. `null` 그리고 `undefined`를 제외한 모든 원시형은 이러한 행동을 합니다.
@@ -1222,9 +1220,9 @@ JavaScript는 원시형과 객체만 가지고 있어요.
#### 정답: C
-`[1, 2]`은 초기값이에요. 이것이 최초의 값으로, 제일 처음의 `acc`의 값이에요. 처음 라운드 동안에 `acc`은 `[1,2]`이며, `cur`은 `[0, 1]`이에요. 그것들을 연결하면 결과적으로 `[1, 2, 0, 1]`이 되요.
+`[1, 2]`은 초기값이에요. 이것이 최초의 값으로, 제일 처음의 `acc`의 값이에요. 처음 라운드 동안에 `acc`은 `[1,2]`이며, `cur`은 `[0, 1]`이에요. 그것들을 연결하면 결과적으로 `[1, 2, 0, 1]`이 돼요.
-그리고나서, `[1, 2, 0, 1]`은 `acc`이고, `[2, 3]`은 `cur`이 에요. 그것들을 연결하면 `[1, 2, 0, 1, 2, 3]`을 얻게되요.
+그 후, `[1, 2, 0, 1]`은 `acc`이고, `[2, 3]`은 `cur`이 에요. 그것들을 연결하면 `[1, 2, 0, 1, 2, 3]`을 얻게 돼요.
@@ -1276,7 +1274,7 @@ setInterval(() => console.log("Hi"), 1000);
#### 정답: A
-이것은 유니크한 id를 리턴해요. 이 id는 `clearInterval()` 함수로 간격을 없애기 위해 사용 될 수 있어요.
+이것은 유니크한 id를 리턴해요. 이 id는 `clearInterval()` 함수로 간격을 없애기 위해 사용될 수 있어요.
@@ -1299,7 +1297,7 @@ setInterval(() => console.log("Hi"), 1000);
#### 정답: A
-문자열은 반복 가능한 객체에요. 스프레드 연산자는 반복 가능한 객체의 모든 문자를 1개의 요소로 매핑해요.
+문자열은 반복 가능한 객체예요. 스프레드 연산자는 반복 가능한 객체의 모든 문자를 1개의 요소로 매핑해요.
@@ -1330,11 +1328,11 @@ console.log(gen.next().value);
#### 정답: C
-Regular functions cannot be stopped mid-way after invocation. However, a generator function can be "stopped" midway, and later continue from where it stopped. Every time a generator function encounters a `yield` keyword, the function yields the value specified after it. Note that the generator function in that case doesn’t _return_ the value, it _yields_ the value.
+보통의 함수는 호출 후에 중단할 수 없어요. 하지만, 제너레이터 함수는 중간에 "멈췄다가", 나중에 중단된 부분부터 계속할 수 있어요. 제너레이터 함수는 `yield` 키워드를 만날 때마다, yield 뒤에 지정된 값을 넘겨줘요. 제너레이터 함수에서는 값을 _리턴_ 하지 않고, _넘겨준다_ 는 것을 유의하세요.
-First, we initialize the generator function with `i` equal to `10`. We invoke the generator function using the `next()` method. The first time we invoke the generator function, `i` is equal to `10`. It encounters the first `yield` keyword: it yields the value of `i`. The generator is now "paused", and `10` gets logged.
+우선, 제너레이터 함수에서 `i`를 `10`로 초기화해요. `next()` 메소드를 사용해 제너레이터 함수를 호출해요. 처음에 제너레이터 함수를 호출하면, `i`은 `10`이에요. 첫 번째 `yield` 키워드를 만났어요: 그것은 `i`의 값을 넘겨줘요. 이제 제너레이터는 "멈추고", `10`을 출력해요.
-Then, we invoke the function again with the `next()` method. It starts to continue where it stopped previously, still with `i` equal to `10`. Now, it encounters the next `yield` keyword, and yields `i * 2`. `i` is equal to `10`, so it returns `10 * 2`, which is `20`. This results in `10, 20`.
+그 후, `next()` 메소드를 사용해 다시 한번 함수를 호출해요. `i`는 여전히 `10`이에요. 이제, 다음 `yield` 키워드를 만나 `i * 2`를 넘겨줘요. `i`는 `10`이므로, `10 * 2`, 즉 `20`을 리턴해요. 결과는 `10, 20`이에요.
@@ -1365,7 +1363,7 @@ Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
#### 정답: B
-When we pass multiple promises to the `Promise.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged.
+복수의 프로미스를 `Promise.race` 메소드에 넘겨주면, _최초_ 의 프로미스를 해결/거부 해요. `setTimeout` 메소드에 타이머를 전달해요: 첫번째 프로미스(`firstPromise`)에는 500ms, 두번째 프로미스(`secondPromise`)에는 100ms. 이것은 `'two'`의 값을 가진 `secondPromise`가 최초로 해결한다는 것을 의미해요. 이제 `res`는 `'two'`의 값을 유지하고 출력되요.
@@ -1392,19 +1390,19 @@ console.log(members);
#### 정답: D
-First, we declare a variable `person` with the value of an object that has a `name` property.
+우선, 변수 `person`의 값을 `name`속성을 가진 객체로 선언해요.
-Then, we declare a variable called `members`. We set the first element of that array equal to the value of the `person` variable. Objects interact by _reference_ when setting them equal to each other. When you assign a reference from one variable to another, you make a _copy_ of that reference. (note that they don't have the _same_ reference!)
+그 후, `members`라는 변수를 선언해요. 배열의 첫 번째 요소에 `person`변수의 값을 대입해요. 서로를 같게 설정하면 _참조_ 에 의해 상호작용해요. 어떤 변수에서 다른 변수로 참조를 할당하면, 그 참조의 _복사본_ 을 만들어요. (그들은 _같은_ 참조를 가지고 있지 않다는 것을 유의하세요!)
-Then, we set the variable `person` equal to `null`.
+그리고, 변수 `person`를 `null`로 설정해요.
-We are only modifying the value of the `person` variable, and not the first element in the array, since that element has a different (copied) reference to the object. The first element in `members` still holds its reference to the original object. When we log the `members` array, the first element still holds the value of the object, which gets logged.
+배열의 첫 번째 요소는 객체에 대한 다른 (복사된) 참조를 가지고 있기 때문에, `person` 변수의 값만 변경하고, 배열의 첫번째 요소는 변경할 수 없어요. `members`의 첫 번째 요소는 여전히 원본 객체에 대한 참조를 유지하고 있어요. `members` 배열을 출력할 때, 첫 번째 요소는 여전히 객체의 값을 유지하고 있어 로그가 출력돼요.
@@ -1434,7 +1432,7 @@ for (const item in person) {
#### 정답: B
-With a `for-in` loop, we can iterate through object keys, in this case `name` and `age`. Under the hood, object keys are strings (if they're not a Symbol). On every loop, we set the value of `item`equal to the current key it’s iterating over. First, `item` is equal to `name`, and gets logged. Then, `item` is equal to `age`, which gets logged.
+`for-in` 루프를 사용하면, 객체 키를 통해서 반복할 수 있는데, 이경우에서는 `name` 그리고 `age`에요. 내부적으로, 객체 키는 문자열이에요 (심볼이 아니라면 말이죠). 모든 루프에서, `item`의 값은 반복되어 있는 현재의 키 값으로 설정해요. 우선, `item`은 `name`가 대입되어, 로그로 출력돼요. 그 후, `item`은 `age`가 대입되어, 로그로 출력돼요.
@@ -1457,18 +1455,18 @@ console.log(3 + 4 + "5");
#### 정답: B
-Operator associativity is the order in which the compiler evaluates the expressions, either left-to-right or right-to-left. This only happens if all operators have the _same_ precedence. We only have one type of operator: `+`. For addition, the associativity is left-to-right.
+연산자 결합성은 왼쪽에서 오른쪽 또는 오른쪽에서 왼쪽으로 컴파일러가 표현식을 평가하는 순서가 되요. 이것은 연산자가 _같은_ 우선순위를 가진 경우에만 해당되요. 연산자의 종류는 한개뿐이에요: `+`. 게다가, 결합성은 왼쪽에서 오른쪽이에요.
-`3 + 4` gets evaluated first. This results in the number `7`.
+처음으로 `3 + 4`가 평가되요. 결과는 숫자 `7`이에요.
-`7 + '5'` results in `"75"` because of coercion. JavaScript converts the number `7` into a string, see question 15. We can concatenate two strings using the `+`operator. `"7" + "5"` results in `"75"`.
+`7 + '5'`의 결과는 강제성 때문에 `"75"`가 돼요. JavaScript는 숫자 `7`을 문자열로 변환하고, (자세한 내용은)질문 15를 보세요. `+` 연산자를 사용해서 두 개의 문자열을 연결할 수 있어요. `"7" + "5"`의 결과는 `"75"`이에요.
---
-###### 49. What's the value of `num`?
+###### 49. `num`의 값은 무엇일까요?
```javascript
const num = parseInt("7*6", 10);
@@ -1484,16 +1482,16 @@ const num = parseInt("7*6", 10);
#### 정답: C
-Only the first numbers in the string is returned. Based on the _radix_ (the second argument in order to specify what type of number we want to parse it to: base 10, hexadecimal, octal, binary, etc.), the `parseInt` checks whether the characters in the string are valid. Once it encounters a character that isn't a valid number in the radix, it stops parsing and ignores the following characters.
+문자열의 첫 번째 숫자만 리턴돼요. _진법_ 에 근거하여 (파싱 하고자 하는 숫자의 기준을 명시하기 위한 두 번째 인수: 기본적인 10진수, 6진수, 8진수, 2진수 등), `parseInt`는 문자열 내의 문자가 타당한지 여부를 확인해요. 진수에 유효한 숫자가 아닌 문자를 만나면, 파싱을 멈추고, 다음 문자를 무시해요.
-`*` is not a valid number. It only parses `"7"` into the decimal `7`. `num` now holds the value of `7`.
+`*`은 유요한 숫자가 아니에요. `"7"`만 십진수의 `7`으로 파싱 돼요. 이제 `num`은 `7`의 값을 유지해요.
---
-###### 50. What's the output`?
+###### 50. 무엇이 출력 될까요?
```javascript
[1, 2, 3].map(num => {
@@ -1512,9 +1510,9 @@ Only the first numbers in the string is returned. Based on the _radix_ (the seco
#### 정답: C
-When mapping over the array, the value of `num` is equal to the element it’s currently looping over. In this case, the elements are numbers, so the condition of the if statement `typeof num === "number"` returns `true`. The map function creates a new array and inserts the values returned from the function.
+배열을 매핑할 때, `num`의 값은 헌재 순환하고 있는 요소예요. 이 경우, 요소는 숫자이기 때문에, if문의 조건 `typeof num === "number"`는 `true`를 리턴해요. map 합수는 새로운 배열을 만들고 함수에서 리턴된 값을 삽입해요.
-However, we don’t return a value. When we don’t return a value from the function, the function returns `undefined`. For every element in the array, the function block gets called, so for each element we return `undefined`.
+그러나, 값을 리턴하지 않아요. 함수는 값을 리턴하지 않을 때, `undefined`을 리턴해요. 배열에서의 모든 요소에 대해 블록 함수가 호출되기 때문에, 각 요소에 대해 `undefined`을 리턴해요.
@@ -1547,11 +1545,11 @@ console.log(person, birthYear);
#### 정답: A
-Arguments are passed by _value_, unless their value is an object, then they're passed by _reference_. `birthYear` is passed by value, since it's a string, not an object. When we pass arguments by value, a _copy_ of that value is created (see question 46).
+인수들의 값이 객체가 아닌 한 _값_ 에 의해 전달되요. 그 후 _참조_ 에 의해 전달되요. `birthYear`는 객체가 아니라 문자열이기 때문에 값에 의해 전달되요. 값으로 전달하면 값의 _복사본_ 이 만들어 져요(질문 46을 보세요).
-The variable `birthYear` has a reference to the value `"1997"`. The argument `year` also has a reference to the value `"1997"`, but it's not the same value as `birthYear` has a reference to. When we update the value of `year` by setting `year` equal to `"1998"`, we are only updating the value of `year`. `birthYear` is still equal to `"1997"`.
+변수 `birthYear`는 `"1997"`값에 대한 참조를 가져요. 인수 `year` 또한 `"1997"`에 대한 참조를 가지지만, `birthYear`가 가진 참조값과는 달라요. `year`에 `"1997"`을 대입하여 `year`의 값을 업데이트할 때, `year`의 값만 업데이트해요. `birthYear`는 여전히 `"1997"`이에요.
-The value of `person` is an object. The argument `member` has a (copied) reference to the _same_ object. When we modify a property of the object `member` has a reference to, the value of `person` will also be modified, since they both have a reference to the same object. `person`'s `name` property is now equal to the value `"Lydia"`
+`person`의 값은 객체예요. 인수 `member`는 _같은_ 객체의 (복사된) 참조값을 가져요. `member`객체의 속성이 갖는 참조를 변경하면, 두 개 모두 같은 객체를 참조 값을 가지고 있기 때문에, `person`의 값 또한 변경돼요. 이제 `person`'의 `name` 속성은 값 `"Lydia"`와 같아요.
@@ -1578,18 +1576,18 @@ sayHi();
```
- A: `"It worked! Hello world!"`
-- B: `"Oh no an error: undefined`
+- B: `"Oh no an error! undefined"`
- C: `SyntaxError: can only throw Error objects`
-- D: `"Oh no an error: Hello world!`
+- D: `"Oh no an error! Hello world!"`
정답
#### 정답: D
-With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world'`.
+`throw`문을 사용해, 커스텀 에러를 만들 수 있어요. 이 표현식을 사용해, 예외를 던질 수 있어요. 예외는 string, a number, a boolean or an object이 될 수 있어요. 이 경우, 예외는 `'Hello world'` 문자열이에요.
-With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world'`. `e` is now equal to that string, which we log. This results in `'Oh an error: Hello world'`.
+`catch` 문을 사용해, `try` 블록에서 예외가 던져졌을 경우에 어떻게 할지 명시할 수 있어요. 예외가 던져졌어요: 문자열 `'Hello world'`. `e`는 이제 문자열이고, 그것을 출력해요. 결과는 `'Oh an error: Hello world'`이에요.
@@ -1618,7 +1616,7 @@ console.log(myCar.make);
#### 정답: B
-When you return a property, the value of the property is equal to the _returned_ value, not the value set in the constructor function. We return the string `"Maserati"`, so `myCar.make` is equal to `"Maserati"`.
+속성을 리턴할 때, 속성 값은 생성자에 설정한 값이 아닌, _리턴된_ 값과 같아요. `"Maserati"` 문자열을 리턴하기 때문에, `myCar.make`는 `"Maserati"`에요.
@@ -1646,18 +1644,18 @@ console.log(typeof y);
#### 정답: A
-`let x = y = 10;` is actually shorthand for:
+`let x = y = 10;`은 다음의 단축형이에요:
```javascript
y = 10;
let x = y;
```
-When we set `y` equal to `10`, we actually add a property `y` to the global object (`window` in browser, `global` in Node). In a browser, `window.y` is now equal to `10`.
+`y`에 `10`을 대입하면, 실제로는 전역 객체에 속성 `y`를 추가해요(브라우저에서는 `window`, Node에서는 `global`). 브라우저에서, `window.y`는 이제 `10`이에요.
-Then, we declare a variable `x` with the value of `y`, which is `10`. Variables declared with the `let` keyword are _block scoped_, they are only defined within the block they're declared in; the immediately-invoked function (IIFE) in this case. When we use the `typeof` operator, the operand `x` is not defined: we are trying to access `x` outside of the block it's declared in. This means that `x` is not defined. Values who haven't been assigned a value or declared are of type `"undefined"`. `console.log(typeof x)` returns `"undefined"`.
+그 후, 변수 `x`를 `10`인 `y`를 값으로 선언해요. `let`키워드로 선언된 변수는 _블록 스코프_ 로, 선언된 블록 내에서만 정의돼요: 이경우 즉시 호출 함수예요(IIFE). `typeof`연산자를 사용할 때, 피연산자 `x`는 정의되지 않았어요: 선언된 블록 밖에서 접근하려 했어요. 이것은 `x`가 선언되지 않음을 의미해요. 값을 할당하거나 선언하지 않은 변수는 `"undefined"` 형이에요. `console.log(typeof x)`는 `"undefined"`를 리턴해요.
-However, we created a global variable `y` when setting `y` equal to `10`. This value is accessible anywhere in our code. `y` is defined, and holds a value of type `"number"`. `console.log(typeof y)` returns `"number"`.
+그러나, `y`를 `10`으로 설정할 때 전역 변수 `y`를 만들었어요. 이 값은 코드 내 어디에서나 접근할 수 있어요. `y`는 정의되었고, `"number"`형의 값을 유지해요. `console.log(typeof y)`는 `"number"`을 리턴해요.
From 6564cf1489c7c9ade6b4ad5d1d2647d4823bf800 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 14:06:09 +0200
Subject: [PATCH 099/881] Questions 41-43 translated into Arabic
---
README_AR.md | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/README_AR.md b/README_AR.md
index b4b9e260..0fd44e7e 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -1266,3 +1266,88 @@ console.log(numbers);
---
+
+41. ماهو الناتج؟
+
+```javascript
+!!null;
+!!"";
+!!1;
+```
+
+- A: `false` `true` `false`
+- B: `false` `false` `true`
+- C: `false` `true` `true`
+- D: `true` `true` `false`
+
+الإجابة
+
+
+الجواب هو الخيارالثاني: B
+
+`null` هي قيمة خطئية. `!null` تقوم بإرجاع `true`. `!true` تقوم بإرجاع `false`.
+
+`""` هي قيمة خطئية. `!""` تقوم بإرجاع `true`. `!true` تقوم بإرجاع `false`.
+
+`1` هي قيمة صحيحية. `!1` تقوم بإرجاع `false`. `!false` تقوم بإرجاع `true`.
+
+
+
+
+
+---
+
+
+42. ماهو الذي تقوم الدالة `setInterval` بإرجاع في المتصفح؟
+
+
+```javascript
+setInterval(() => console.log("Hi"), 1000);
+```
+
+
+- A: فريد id
+
+- B: قيمة ال milliseconds محددة.
+
+- C: الدالة التي تم تمريرها
+
+- D: `undefined`
+
+
+
+الإجابة
+
+
+الجواب هو الخيار الأول: A
+
+تقوم بإرجاع ال id الفريد, هذا الid يمكن استخدامه لكي يقوم بتصفير عداد الفترات المفصلة عن طريق استخدام الدالة `clearInterval()`
+
+
+
+
+---
+
+43. مالذي يتم ارجاعه بعد تنفيذ الكود أدناه؟
+
+```javascript
+[..."Lydia"];
+```
+
+- A: `["L", "y", "d", "i", "a"]`
+- B: `["Lydia"]`
+- C: `[[], "Lydia"]`
+- D: `[["L", "y", "d", "i", "a"]]`
+
+الإجابة
+
+
+الجواب هو الخيار الأول: A
+
+الstring هي تكرارية, و عملية الspread (...) تقوم بتحويل اي حرف ينتمي الى فئة تكرارية الى عنصر منفرد واحد.
+
+
+
+
+---
+
From 811f3637bccf8c6fd086b486daebafcd872cebad Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 14:13:59 +0200
Subject: [PATCH 100/881] Update README_AR.md
---
README_AR.md | 374 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 365 insertions(+), 9 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index 0fd44e7e..fa8b5802 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -1285,11 +1285,12 @@ console.log(numbers);
الجواب هو الخيارالثاني: B
-`null` هي قيمة خطئية. `!null` تقوم بإرجاع `true`. `!true` تقوم بإرجاع `false`.
-
-`""` هي قيمة خطئية. `!""` تقوم بإرجاع `true`. `!true` تقوم بإرجاع `false`.
-
-`1` هي قيمة صحيحية. `!1` تقوم بإرجاع `false`. `!false` تقوم بإرجاع `true`.
+`null` is falsy. `!null` returns `true`. `!true` returns `false`.
+`null` هي قيمة خطئية, `!null` تقوم بإرجاع `true`. `!true` تقوم بإرجاع `false`.
+`""` is falsy. `!""` returns `true`. `!true` returns `false`.
+`""` هي قيمة خطئية, `!""` تقوم بإرجاع `true` . `!true` تقوم بإرجاع `false`.
+`1` is truthy. `!1` returns `false`. `!false` returns `true`.
+`1` هي قيمة صحيحية. `!1` تقوم بإرجاع `false`. `!false` تقوم بإرجاع `true`.
@@ -1306,13 +1307,13 @@ setInterval(() => console.log("Hi"), 1000);
```
-- A: فريد id
+- A: فريد id
-- B: قيمة ال milliseconds محددة.
+- B: قيمة ال milliseconds محددة.
-- C: الدالة التي تم تمريرها
+- C: الدالة التي تم تمريرها
-- D: `undefined`
+- D: `undefined`
@@ -1351,3 +1352,358 @@ setInterval(() => console.log("Hi"), 1000);
---
+###### 44. What's the output?
+
+```javascript
+function* generator(i) {
+ yield i;
+ yield i * 2;
+}
+
+const gen = generator(10);
+
+console.log(gen.next().value);
+console.log(gen.next().value);
+```
+
+- A: `[0, 10], [10, 20]`
+- B: `20, 20`
+- C: `10, 20`
+- D: `0, 10 and 10, 20`
+
+
Answer
+
+
+#### Answer: C
+
+Regular functions cannot be stopped mid-way after invocation. However, a generator function can be "stopped" midway, and later continue from where it stopped. Every time a generator function encounters a `yield` keyword, the function yields the value specified after it. Note that the generator function in that case doesn’t _return_ the value, it _yields_ the value.
+
+First, we initialize the generator function with `i` equal to `10`. We invoke the generator function using the `next()` method. The first time we invoke the generator function, `i` is equal to `10`. It encounters the first `yield` keyword: it yields the value of `i`. The generator is now "paused", and `10` gets logged.
+
+Then, we invoke the function again with the `next()` method. It starts to continue where it stopped previously, still with `i` equal to `10`. Now, it encounters the next `yield` keyword, and yields `i * 2`. `i` is equal to `10`, so it returns `10 * 2`, which is `20`. This results in `10, 20`.
+
+
+
+
+---
+
+###### 45. What does this return?
+
+```javascript
+const firstPromise = new Promise((res, rej) => {
+ setTimeout(res, 500, "one");
+});
+
+const secondPromise = new Promise((res, rej) => {
+ setTimeout(res, 100, "two");
+});
+
+Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
+```
+
+- A: `"one"`
+- B: `"two"`
+- C: `"two" "one"`
+- D: `"one" "two"`
+
+
Answer
+
+
+#### Answer: B
+
+When we pass multiple promises to the `Promise.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged.
+
+
+
+
+---
+
+###### 46. What's the output?
+
+```javascript
+let person = { name: "Lydia" };
+const members = [person];
+person = null;
+
+console.log(members);
+```
+
+- A: `null`
+- B: `[null]`
+- C: `[{}]`
+- D: `[{ name: "Lydia" }]`
+
+
Answer
+
+
+#### Answer: D
+
+First, we declare a variable `person` with the value of an object that has a `name` property.
+
+
+
+Then, we declare a variable called `members`. We set the first element of that array equal to the value of the `person` variable. Objects interact by _reference_ when setting them equal to each other. When you assign a reference from one variable to another, you make a _copy_ of that reference. (note that they don't have the _same_ reference!)
+
+
+
+Then, we set the variable `person` equal to `null`.
+
+
+
+We are only modifying the value of the `person` variable, and not the first element in the array, since that element has a different (copied) reference to the object. The first element in `members` still holds its reference to the original object. When we log the `members` array, the first element still holds the value of the object, which gets logged.
+
+
+
+
+---
+
+###### 47. What's the output?
+
+```javascript
+const person = {
+ name: "Lydia",
+ age: 21
+};
+
+for (const item in person) {
+ console.log(item);
+}
+```
+
+- A: `{ name: "Lydia" }, { age: 21 }`
+- B: `"name", "age"`
+- C: `"Lydia", 21`
+- D: `["name", "Lydia"], ["age", 21]`
+
+
Answer
+
+
+#### Answer: B
+
+With a `for-in` loop, we can iterate through object keys, in this case `name` and `age`. Under the hood, object keys are strings (if they're not a Symbol). On every loop, we set the value of `item`equal to the current key it’s iterating over. First, `item` is equal to `name`, and gets logged. Then, `item` is equal to `age`, which gets logged.
+
+
+
+
+---
+
+###### 48. What's the output?
+
+```javascript
+console.log(3 + 4 + "5");
+```
+
+- A: `"345"`
+- B: `"75"`
+- C: `12`
+- D: `"12"`
+
+
Answer
+
+
+#### Answer: B
+
+Operator associativity is the order in which the compiler evaluates the expressions, either left-to-right or right-to-left. This only happens if all operators have the _same_ precedence. We only have one type of operator: `+`. For addition, the associativity is left-to-right.
+
+`3 + 4` gets evaluated first. This results in the number `7`.
+
+`7 + '5'` results in `"75"` because of coercion. JavaScript converts the number `7` into a string, see question 15. We can concatenate two strings using the `+`operator. `"7" + "5"` results in `"75"`.
+
+
+
+
+---
+
+###### 49. What's the value of `num`?
+
+```javascript
+const num = parseInt("7*6", 10);
+```
+
+- A: `42`
+- B: `"42"`
+- C: `7`
+- D: `NaN`
+
+
Answer
+
+
+#### Answer: C
+
+Only the first numbers in the string is returned. Based on the _radix_ (the second argument in order to specify what type of number we want to parse it to: base 10, hexadecimal, octal, binary, etc.), the `parseInt` checks whether the characters in the string are valid. Once it encounters a character that isn't a valid number in the radix, it stops parsing and ignores the following characters.
+
+`*` is not a valid number. It only parses `"7"` into the decimal `7`. `num` now holds the value of `7`.
+
+
+
+
+---
+
+###### 50. What's the output`?
+
+```javascript
+[1, 2, 3].map(num => {
+ if (typeof num === "number") return;
+ return num * 2;
+});
+```
+
+- A: `[]`
+- B: `[null, null, null]`
+- C: `[undefined, undefined, undefined]`
+- D: `[ 3 x empty ]`
+
+
Answer
+
+
+#### Answer: C
+
+When mapping over the array, the value of `num` is equal to the element it’s currently looping over. In this case, the elements are numbers, so the condition of the if statement `typeof num === "number"` returns `true`. The map function creates a new array and inserts the values returned from the function.
+
+However, we don’t return a value. When we don’t return a value from the function, the function returns `undefined`. For every element in the array, the function block gets called, so for each element we return `undefined`.
+
+
+
+
+---
+
+###### 51. What's the output?
+
+```javascript
+function getInfo(member, year) {
+ member.name = "Lydia";
+ year = 1998;
+}
+
+const person = { name: "Sarah" };
+const birthYear = "1997";
+
+getInfo(person, birthYear);
+
+console.log(person, birthYear);
+```
+
+- A: `{ name: "Lydia" }, "1997"`
+- B: `{ name: "Sarah" }, "1998"`
+- C: `{ name: "Lydia" }, "1998"`
+- D: `{ name: "Sarah" }, "1997"`
+
+
Answer
+
+
+#### Answer: A
+
+Arguments are passed by _value_, unless their value is an object, then they're passed by _reference_. `birthYear` is passed by value, since it's a string, not an object. When we pass arguments by value, a _copy_ of that value is created (see question 46).
+
+The variable `birthYear` has a reference to the value `"1997"`. The argument `year` also has a reference to the value `"1997"`, but it's not the same value as `birthYear` has a reference to. When we update the value of `year` by setting `year` equal to `"1998"`, we are only updating the value of `year`. `birthYear` is still equal to `"1997"`.
+
+The value of `person` is an object. The argument `member` has a (copied) reference to the _same_ object. When we modify a property of the object `member` has a reference to, the value of `person` will also be modified, since they both have a reference to the same object. `person`'s `name` property is now equal to the value `"Lydia"`
+
+
+
+
+---
+
+###### 52. What's the output?
+
+```javascript
+function greeting() {
+ throw "Hello world!";
+}
+
+function sayHi() {
+ try {
+ const data = greeting();
+ console.log("It worked!", data);
+ } catch (e) {
+ console.log("Oh no an error!", e);
+ }
+}
+
+sayHi();
+```
+
+- A: `"It worked! Hello world!"`
+- B: `"Oh no an error: undefined`
+- C: `SyntaxError: can only throw Error objects`
+- D: `"Oh no an error: Hello world!`
+
+
Answer
+
+
+#### Answer: D
+
+With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world'`.
+
+With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world'`. `e` is now equal to that string, which we log. This results in `'Oh an error: Hello world'`.
+
+
+
+
+---
+
+###### 53. What's the output?
+
+```javascript
+function Car() {
+ this.make = "Lamborghini";
+ return { make: "Maserati" };
+}
+
+const myCar = new Car();
+console.log(myCar.make);
+```
+
+- A: `"Lamborghini"`
+- B: `"Maserati"`
+- C: `ReferenceError`
+- D: `TypeError`
+
+
Answer
+
+
+#### Answer: B
+
+When you return a property, the value of the property is equal to the _returned_ value, not the value set in the constructor function. We return the string `"Maserati"`, so `myCar.make` is equal to `"Maserati"`.
+
+
+
+
+---
+
+###### 54. What's the output?
+
+```javascript
+(() => {
+ let x = (y = 10);
+})();
+
+console.log(typeof x);
+console.log(typeof y);
+```
+
+- A: `"undefined", "number"`
+- B: `"number", "number"`
+- C: `"object", "number"`
+- D: `"number", "undefined"`
+
+
Answer
+
+
+#### Answer: A
+
+`let x = y = 10;` is actually shorthand for:
+
+```javascript
+y = 10;
+let x = y;
+```
+
+When we set `y` equal to `10`, we actually add a property `y` to the global object (`window` in browser, `global` in Node). In a browser, `window.y` is now equal to `10`.
+
+Then, we declare a variable `x` with the value of `y`, which is `10`. Variables declared with the `let` keyword are _block scoped_, they are only defined within the block they're declared in; the immediately-invoked function (IIFE) in this case. When we use the `typeof` operator, the operand `x` is not defined: we are trying to access `x` outside of the block it's declared in. This means that `x` is not defined. Values who haven't been assigned a value or declared are of type `"undefined"`. `console.log(typeof x)` returns `"undefined"`.
+
+However, we created a global variable `y` when setting `y` equal to `10`. This value is accessible anywhere in our code. `y` is defined, and holds a value of type `"number"`. `console.log(typeof y)` returns `"number"`.
+
+
+
From 69c1e1dcc1b594451a1ac69212c10e33c23c8811 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 15:45:55 +0200
Subject: [PATCH 101/881] =?UTF-8?q?=D9=8EQuestions=2044=20-=2050=20transla?=
=?UTF-8?q?ted=20into=20Arabic?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README_AR.md | 163 +++++++++++++++++++++++++++++----------------------
1 file changed, 92 insertions(+), 71 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index fa8b5802..8c816a9e 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -1285,12 +1285,25 @@ console.log(numbers);
الجواب هو الخيارالثاني: B
-`null` is falsy. `!null` returns `true`. `!true` returns `false`.
-`null` هي قيمة خطئية, `!null` تقوم بإرجاع `true`. `!true` تقوم بإرجاع `false`.
-`""` is falsy. `!""` returns `true`. `!true` returns `false`.
-`""` هي قيمة خطئية, `!""` تقوم بإرجاع `true` . `!true` تقوم بإرجاع `false`.
-`1` is truthy. `!1` returns `false`. `!false` returns `true`.
-`1` هي قيمة صحيحية. `!1` تقوم بإرجاع `false`. `!false` تقوم بإرجاع `true`.
+`null` قيمة خطئية.
+
+`!null` تقوم بإرجاع `true`.
+
+`!true` تقوم بإرجاع `false`.
+*********
+
+`""` قيمة خطئية.
+
+`!""`تقوم بإرجاع `true`.
+
+`!true` تقوم بإرجاع `false`.
+*********
+
+`1` قيمة صحيحية.
+
+`!1` تقوم بإرجاع `false`.
+
+`!false` تقوم بإرجاع `true`.
@@ -1352,7 +1365,7 @@ setInterval(() => console.log("Hi"), 1000);
---
-###### 44. What's the output?
+44. ماهو الناتج؟
```javascript
function* generator(i) {
@@ -1371,23 +1384,23 @@ console.log(gen.next().value);
- C: `10, 20`
- D: `0, 10 and 10, 20`
-
Answer
+الإجابة
+
+الجواب هو الخيار الثالث: C
-#### Answer: C
-
-Regular functions cannot be stopped mid-way after invocation. However, a generator function can be "stopped" midway, and later continue from where it stopped. Every time a generator function encounters a `yield` keyword, the function yields the value specified after it. Note that the generator function in that case doesn’t _return_ the value, it _yields_ the value.
-
-First, we initialize the generator function with `i` equal to `10`. We invoke the generator function using the `next()` method. The first time we invoke the generator function, `i` is equal to `10`. It encounters the first `yield` keyword: it yields the value of `i`. The generator is now "paused", and `10` gets logged.
+الدوال العادية ليس بإمكانها ان تتوقف في وسط التنفيذ بعد أن يتم مناداتها, و لكن الدوال من نوع generator من الممكن أن يتم ايقافها وسط التنفيذ, و لاحقا يتم مواصلة تنفيذها من حيث المكان الذي توقفت به. في كل مرة تواجه فيها الدالة من نوع generator الكلمة المفتاحية `yield`, فإن الدالة تخضع أو تستسلم للقيمة المحددة بعدها. مع ملاحظة أن الدالة من نوع generator في هذه الحالة, لاتقوم بإرجاع القيمة, يل تخضع لتلك القيمة.
-Then, we invoke the function again with the `next()` method. It starts to continue where it stopped previously, still with `i` equal to `10`. Now, it encounters the next `yield` keyword, and yields `i * 2`. `i` is equal to `10`, so it returns `10 * 2`, which is `20`. This results in `10, 20`.
+أولا, نقوم بإنشاء الدالة من نوع generator مع وجود المتغير `i` مساوي ل `10`. نقوم بمناداة الدالةمن نوع generator باستخدام الدالة `next()`. في المرة الأولى التي ننادي فيها الدالة من نوع generator, فإن ال `i` تساوي `10`. هي تواجه الكلمة المفتاحية `yield`, فتخضع لقيمة ال `i`. الدالة generator في هذه اللحظة تم توقيفها مؤقتا, و القيمة `10` تم طباعتها عن طريق log.
+اذاً, نقوم بمناداة الدالة مرة أخرى عن طريق الدالة `next()`, هي تبدأ لتواصل من المكان الذي تم توقفيها فيه مؤقتا سابقاً, و ماتزال قيمة `i` تساوي `10`. الآن هي تواجه الكلمة المفتاحية `yield` التالية, و تواجه `i * 2`. `i` تساوي `10`,لهذا تقوم بإرجاع `10 * 2` و التي هي تساوي `20`, و هذا سيوصلنا للنتيجة `10, 20`.
+
---
-###### 45. What does this return?
+45. ما الذي يتم ارجاعه عند تنفيذ الكود؟
```javascript
const firstPromise = new Promise((res, rej) => {
@@ -1406,19 +1419,19 @@ Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
- C: `"two" "one"`
- D: `"one" "two"`
-Answer
+الإجابة
+
+الجواب هو الخيار الثاني: B
-#### Answer: B
-
-When we pass multiple promises to the `Promise.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged.
-
+عندما نقوم بتمرير عدد من الpromises للدالة `Promise.race`. فهي تقوم برفض أو فصل الpromise الاولى. للدالة `setTimeout` نحن نقوم بتمرير timer: 500ms لل promise الأولى و التي هي (`firstPromise`), و 100ms اي 100ملي ثانية للpromise الثانية والتي هي (`secondPromise`) هذا يعني ان ال `secondPromise` يتم فصلها اولاً مع القيمة `'two'`. `res` الآن تحمل قيمة `'two'`, وهي التي تم طباعتها عن طريق الlog.
+
---
-###### 46. What's the output?
+46. ماهو الناتج؟
```javascript
let person = { name: "Lydia" };
@@ -1433,31 +1446,32 @@ console.log(members);
- C: `[{}]`
- D: `[{ name: "Lydia" }]`
-Answer
+الإجابة
+
+الجواب هو الخيار الرابع: D
-#### Answer: D
-
-First, we declare a variable `person` with the value of an object that has a `name` property.
+أولا, نقوم بتعريف المتغير `person` مع قيمة عبارة عن object لديه الخاصية `name`.

-Then, we declare a variable called `members`. We set the first element of that array equal to the value of the `person` variable. Objects interact by _reference_ when setting them equal to each other. When you assign a reference from one variable to another, you make a _copy_ of that reference. (note that they don't have the _same_ reference!)
+ثم ,نقوم بتعريف المتغير الذي يسمى ب `members`. نقوم بضيط قيمة أول عنصر في ال array بالقيمة التي يحملها المتغير `person`.
+الobjects تتفاعل عن طريق الrefrence عندما نقوم بضبطها مساويةً لبعضها البعض, عندما تقوم بتعريف أو إنشاء refrence معين من متغير الى متغير آخر, أنت فعليا تقوم بعمل نسخة من ذلك الrefrence. (مع ملاحظة أنهم ليس لديهم نفس الrefrence)

-Then, we set the variable `person` equal to `null`.
+ثم , نقوم بضبط قمية المتغير `person` بقيمة تساوي `null`.

-We are only modifying the value of the `person` variable, and not the first element in the array, since that element has a different (copied) reference to the object. The first element in `members` still holds its reference to the original object. When we log the `members` array, the first element still holds the value of the object, which gets logged.
-
+نحن فقط نقوم بتعديل قيمة المتغير `person`, وليس أول عنصر في ال array, بما أن ذلك العنصر لديه refrence منسوخ من ال object. أول عنصر في `members` لا يزال لديه refrence للobject الأصلي. و عندما نقوم بطباع الarray `members` عن طريق الlog, فإن العنصر الأول لايزال يحمل قيمة الobject, و التي سيتم طباعتها عن طريق log.
+
---
-###### 47. What's the output?
+47. ماهو الناتج؟
```javascript
const person = {
@@ -1475,19 +1489,19 @@ for (const item in person) {
- C: `"Lydia", 21`
- D: `["name", "Lydia"], ["age", 21]`
-Answer
+الإجابة
-
+
#### Answer: B
-With a `for-in` loop, we can iterate through object keys, in this case `name` and `age`. Under the hood, object keys are strings (if they're not a Symbol). On every loop, we set the value of `item`equal to the current key it’s iterating over. First, `item` is equal to `name`, and gets logged. Then, `item` is equal to `age`, which gets logged.
-
+بإستخدام `for-in` التكرارية, بامكاننا أن نصل الى جميع المفاتيح التي تخص object معين. في هذه الحالة `name` و `age`. ماوراء الكواليس, مفاتيح ال objects هي عبارة عن strings (إذا لم تكن هذه المفاتيح عبارة عن symbol), في أي حلقة من الحلقات التكرارية, نقوم بضبط القيمة `item`مساوية للمفتاح الحالي الذي هي تتكرر فيه اوعنده. أولا `item` تساوي `name`, و يتم طباعتها عن طريق الlog, ثم `item` تساوي `age` و التي ايضا تم طباعتها عن طريق الlog.
+
---
-###### 48. What's the output?
+48. ماهو الناتج؟
```javascript
console.log(3 + 4 + "5");
@@ -1498,23 +1512,26 @@ console.log(3 + 4 + "5");
- C: `12`
- D: `"12"`
-Answer
+الإجابة
+
+الجواب هو الخيار الثاني: B
-#### Answer: B
-
-Operator associativity is the order in which the compiler evaluates the expressions, either left-to-right or right-to-left. This only happens if all operators have the _same_ precedence. We only have one type of operator: `+`. For addition, the associativity is left-to-right.
+Operator associativity او ترابطية العامل هي الترتيب أو التسلسل الذي يقيم به الcompiler ال expressions, ف هو إما أن يكون من اليسار الى اليمين أو من اليمين الى اليسار. هذا يحدث فقط إذا كان جميع الoperators لديها نفس الأسبقية. لدينا فقط نوع واحد من الoperator ألا و هو `+`. بالإضافة الى التالي, الترابطية هي من اليسار الى اليمين.
`3 + 4` gets evaluated first. This results in the number `7`.
+`3 + 4` يتم تقييمها أولا. هذا مايعطينا الناتج الذي هو عبارة عن الرقم `7`.
-`7 + '5'` results in `"75"` because of coercion. JavaScript converts the number `7` into a string, see question 15. We can concatenate two strings using the `+`operator. `"7" + "5"` results in `"75"`.
-
+`7 + '5'` تقوم بإرجاع الناتج `"75"` بسبب عملية ال coercion وهي العمليةالتي تقوم بالتحويل من نوع الى آخر, لغة الجافاسكريبت تقوم بتحويل الرقم `7` الى النوع string, أنظرالى السؤال رقم 15 في الأعلى. بإمكاننا عمل concatenate لمتغيرين من النوع string بإستخدام العملية `+`. `"7" + "5"` سترجع الناتج `"75"`.
+
---
-###### 49. What's the value of `num`?
+
+49. ماهي قيمة `num`؟
+
```javascript
const num = parseInt("7*6", 10);
@@ -1525,21 +1542,21 @@ const num = parseInt("7*6", 10);
- C: `7`
- D: `NaN`
-Answer
+الإجابة
+
+الجواب هو الخيار الثالث: C
-#### Answer: C
-
-Only the first numbers in the string is returned. Based on the _radix_ (the second argument in order to specify what type of number we want to parse it to: base 10, hexadecimal, octal, binary, etc.), the `parseInt` checks whether the characters in the string are valid. Once it encounters a character that isn't a valid number in the radix, it stops parsing and ignores the following characters.
-
-`*` is not a valid number. It only parses `"7"` into the decimal `7`. `num` now holds the value of `7`.
+فقط الأرقام الأولى في الstring يتم إرجاعها. بناءاً على _radix_ (الargument الثاني لكي يتم تحديدنوعية الرقم الذي نود أن نقوم بعمل parse له الى: base 10, hexadecimal, octal, binary, الخ. ). تقوم `parseInt` بالتحقق عن إذا ماكانت الحروف في الstring صالحة. و بمجرد أن تجد حرف غير صالح في ال radix, ف هي تقوم بإيقاف عملية الparsing مباشرة و تتجاهل الحروف التي تليه.
+`*` ليست رقم صالح. هي فقط تقوم بعمل parse ل `"7"` الى عدد عشري `7`. `num` الآن تحمل القيمة `7`.
+
---
-###### 50. What's the output`?
+50. ماهو الناتج؟
```javascript
[1, 2, 3].map(num => {
@@ -1553,21 +1570,21 @@ Only the first numbers in the string is returned. Based on the _radix_ (the seco
- C: `[undefined, undefined, undefined]`
- D: `[ 3 x empty ]`
-Answer
+الإجابة
+
+الجواب هو الخيار الثالث: C
-#### Answer: C
-
-When mapping over the array, the value of `num` is equal to the element it’s currently looping over. In this case, the elements are numbers, so the condition of the if statement `typeof num === "number"` returns `true`. The map function creates a new array and inserts the values returned from the function.
-
-However, we don’t return a value. When we don’t return a value from the function, the function returns `undefined`. For every element in the array, the function block gets called, so for each element we return `undefined`.
+عندما يتم عمل mapping لل array, فإن قيمة `num` ستساوي قيمة العنصر الذي يتم حاليا المرور به, فكما نعرف أن الmapping يدور على جميع عناصر الarray. في هذه الحالة, العناصر عبارة عن أرقام, لهذا فإن شرط ال if statement `typeof num === "number"` يقوم بإرجاع `true`. دالة map تقوم بإنشاء array جديدة, و إدخال القيم المرجعة من الدالة في هذه الarray.
+ولكن, لا نقوم بإرجاع قيمة. عندما لا نقوم بإرجاع قيمة من الدالة, فإن الدالة تقوم بإرجاع `undefined`. لكل عنصرٍ في الarray, فإن نطاق الدالة يتم مناداته, لهذا لأي عنصر نقوم بإرجاع `undefined`.
+
---
-###### 51. What's the output?
+51. ماهو الناتج؟
```javascript
function getInfo(member, year) {
@@ -1588,10 +1605,10 @@ console.log(person, birthYear);
- C: `{ name: "Lydia" }, "1998"`
- D: `{ name: "Sarah" }, "1997"`
-Answer
+الإجابة
-
-#### Answer: A
+
+الجواب هو الخيار الأول: A
Arguments are passed by _value_, unless their value is an object, then they're passed by _reference_. `birthYear` is passed by value, since it's a string, not an object. When we pass arguments by value, a _copy_ of that value is created (see question 46).
@@ -1601,10 +1618,11 @@ The value of `person` is an object. The argument `member` has a (copied) referen
+
---
-###### 52. What's the output?
+52. ماهو الناتج؟
```javascript
function greeting() {
@@ -1628,10 +1646,10 @@ sayHi();
- C: `SyntaxError: can only throw Error objects`
- D: `"Oh no an error: Hello world!`
-Answer
+الإجابة
-
-#### Answer: D
+
+الجواب هو الخيار الرابع: D
With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world'`.
@@ -1639,10 +1657,11 @@ With the `catch` statement, we can specify what to do if an exception is thrown
+
---
-###### 53. What's the output?
+53. ماهو الناتج؟
```javascript
function Car() {
@@ -1659,19 +1678,20 @@ console.log(myCar.make);
- C: `ReferenceError`
- D: `TypeError`
-Answer
+الإجابةAnswer
-
-#### Answer: B
+
+الجواب هو الخيار الثاني: B
When you return a property, the value of the property is equal to the _returned_ value, not the value set in the constructor function. We return the string `"Maserati"`, so `myCar.make` is equal to `"Maserati"`.
+
---
-###### 54. What's the output?
+54. ماهو الناتج؟
```javascript
(() => {
@@ -1687,10 +1707,10 @@ console.log(typeof y);
- C: `"object", "number"`
- D: `"number", "undefined"`
-Answer
+الإجابة
-
-#### Answer: A
+
+الجواب هو الخيار الأول : A
`let x = y = 10;` is actually shorthand for:
@@ -1707,3 +1727,4 @@ However, we created a global variable `y` when setting `y` equal to `10`. This v
+
From 0a594d85266e7367e59aa8952b3fc0a80061e68a Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 16:43:11 +0200
Subject: [PATCH 102/881] Questions 51 - 54 translated into Arabic
---
README_AR.md | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index 8c816a9e..95f93aec 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -1610,12 +1610,11 @@ console.log(person, birthYear);
الجواب هو الخيار الأول: A
-Arguments are passed by _value_, unless their value is an object, then they're passed by _reference_. `birthYear` is passed by value, since it's a string, not an object. When we pass arguments by value, a _copy_ of that value is created (see question 46).
+الArguments يتم تمريرها عن طريق قيمها, إلا في حالة كان قيمتها عبارة عن object, ففي هذه الحالة يتم تمريرها عن طريق الrefrence. `birthYear` تم تمريرها عن طريق القيمة, و بما أنها من النوع string وليس object. عندما نقوم بتمرير الarguments عن طريق القيمة, فإن نسخة من هذه القيمة يتم إنشاءها (أنظر للسؤال رقم 46 في الاعلى).
-The variable `birthYear` has a reference to the value `"1997"`. The argument `year` also has a reference to the value `"1997"`, but it's not the same value as `birthYear` has a reference to. When we update the value of `year` by setting `year` equal to `"1998"`, we are only updating the value of `year`. `birthYear` is still equal to `"1997"`.
-
-The value of `person` is an object. The argument `member` has a (copied) reference to the _same_ object. When we modify a property of the object `member` has a reference to, the value of `person` will also be modified, since they both have a reference to the same object. `person`'s `name` property is now equal to the value `"Lydia"`
+المتغير `birthYear` لديه refrence للقيمة `"1997"`. الargument `year` أيضا لديه refrence للقيمة `"1997"`, لكنها ليست نفس القيمة التي `birthYear` لديها refrence لها. عندما نقوم بتحديث قيمة `year` عن طريق ضبط `year` تساوي ل `"1998"`, نحن فقط نقوم بتحديث قيمة `year`. `birthYear` لا تزال تساوي `"1997"`.
+قيمة `person` هي object. الargument `member` لديه نسخة refrence لنفس الobject. عندما نقوم بتعديل او تحديث خاصية للobject `member`و الذي لديه refrence لها, فإن قيمة `person` ستتعدل و تتغير أيضا,بما أن كلاهما لديهما refrence لنفس الobject. الخصائص `person` و `name` هما الأىن مساويان للقيمة `"Lydia"`.
@@ -1651,10 +1650,9 @@ sayHi();
الجواب هو الخيار الرابع: D
-With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world'`.
-
-With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world'`. `e` is now equal to that string, which we log. This results in `'Oh an error: Hello world'`.
+مع عبارة `throw` , بإمكاننا إنشاء errors حسب الطلب, أي ليست كا الإخطاء العامة في اللغة, بإستخدام هذه العبارة بإمكانك أن تضع exception, الexception يمكن أن يكون : string, a number, a boolean or an object. في هذه الحالة, الexcption لدينا هو ال string `'Hello world'`.
+مع عبارة `catch`, بإمكاننا ان نحدد ما الذي يتوجب فعله عندما يتم وضع أو إلقاء الexception في نطاق ال `try`. تم إلقاء أو وضع exception: الstring `'Hello world'`. `e` الآن تساوي تلك تلك الstring,و هي التي نقوم بطباعتها عن طريق الlgo. هذا سيعطينا النتيجة `'Oh an error: Hello world'`.
@@ -1683,8 +1681,7 @@ console.log(myCar.make);
الجواب هو الخيار الثاني: B
-When you return a property, the value of the property is equal to the _returned_ value, not the value set in the constructor function. We return the string `"Maserati"`, so `myCar.make` is equal to `"Maserati"`.
-
+عندما تقوم بإرجاع خاصية, فإن قيمة هذه الخاصية هي تساوي القيمة المرجعة, ليس القيمة التي تم ضبطها في دالة الconstructor. نقوم بإرجاع الstring `"Maserati"`, لذا فإن `myCar.make` تساوي `"Maserati"`.
@@ -1712,19 +1709,20 @@ console.log(typeof y);
الجواب هو الخيار الأول : A
-`let x = y = 10;` is actually shorthand for:
+`let x = y = 10;` هي في الحقيقة إختصار ل:
+
```javascript
y = 10;
let x = y;
```
-When we set `y` equal to `10`, we actually add a property `y` to the global object (`window` in browser, `global` in Node). In a browser, `window.y` is now equal to `10`.
-
-Then, we declare a variable `x` with the value of `y`, which is `10`. Variables declared with the `let` keyword are _block scoped_, they are only defined within the block they're declared in; the immediately-invoked function (IIFE) in this case. When we use the `typeof` operator, the operand `x` is not defined: we are trying to access `x` outside of the block it's declared in. This means that `x` is not defined. Values who haven't been assigned a value or declared are of type `"undefined"`. `console.log(typeof x)` returns `"undefined"`.
+
+عندما نقوم بضبط قيمة `y` لكي تساوي `10`, فنحن فعليا نقوم بإضافة الخاصية `y` للglopal object. (`window` في المتصفح, `global` في Node). في المتصفح, `window.y` الآن تساوي `10`.
-However, we created a global variable `y` when setting `y` equal to `10`. This value is accessible anywhere in our code. `y` is defined, and holds a value of type `"number"`. `console.log(typeof y)` returns `"number"`.
+ثم, عندما نقوم بتعريف المتغير `x` بالقيمة `y` و التي هي في الحقيقة تساوي `10`. المتغيرات التي يتم تعريفها بالكلمة المفتاحية `let`هي متغيرات block scoped, أي يتم التعامل معها في النطاق الذي تم تعريفها فيه فقط, الدالة المناداة حاليا في هذه الحالة أي immediately-invoked function (IIFE). عندما نقوم بإستخدام العملية `typeof`, فإن المعامل `x` ليس معرف, نحن نحاول الوصول الى `x` خارج النطاق الذي تم تعريفه بها. هذا يعني أن `x` ليست معرفة. المتغيرات التي لم يتم وضع قيمة لها أو لم يتم تعريفها هي من النوع `"undefined"`. `console.log(typeof x)` تقوم بإرجاع `"undefined"`.
+ولكن, نحن قمنا بإنشاء و تعريف global variable `y` عندما قمنا بضبط قيمة `y` لتساوي `10`. هذه القيمة يمكن الوصول إليها من أي مكان في البرنامج. `y` هي معرفة, و لديها قيمة من النوع `"number"`. `console.log(typeof y)` تقوم بإرجاع `"number"`.
From 6b03e0c5192178ea887338d54a9465933ae1fa2b Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 17:12:10 +0200
Subject: [PATCH 103/881] Update the Introduction
---
README_AR.md | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index 95f93aec..57753fd2 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -9,21 +9,23 @@
أقوم بتحديث هذا المستودع أسبوعيا بإضافة المزيد من الأسئلة. :muscle: :rocket:
-الأجوبة توجد في الجزء المطوي بالأسفل أدناه تحت كل سؤال على حدة, فقط قم بالضغط على كلمة الإجابة لكي تحصل على الإجابة, حظا موفقا :heart:
-
-اللغات المتوفرة:
-
-[English](https://github.com/SaraAli26/javascript-questions/blob/master/README.md)
+آخر تحديث: 21 يونيو
-[中文版本](https://github.com/SaraAli26/javascript-questions/blob/master/README-zh_CN.md)
-[Русский](https://github.com/SaraAli26/javascript-questions/blob/master/README_ru-RU.md)
-
-[Western Balkan](https://github.com/SaraAli26/javascript-questions/blob/master/README-bs_BS.md)
+الأجوبة توجد في الجزء المطوي بالأسفل أدناه تحت كل سؤال على حدة, فقط قم بالضغط على كلمة الإجابة لكي تحصل على الإجابة, حظا موفقا :heart:
-[Deutsch](https://github.com/SaraAli26/javascript-questions/blob/master/README-de_DE.md)
+اللغات المتوفرة:
-[Tiếng Việt](https://github.com/SaraAli26/javascript-questions/blob/master/README-vi.md)
+* [English](./README.md)
+* [中文版本](./README-zh_CN.md)
+* [Versión en español](./README-ES.md)
+* [日本語](./README-ja_JA.md)
+* [Русский](./README_ru-RU.md)
+* [Western Balkan](./README-bs_BS.md)
+* [Deutsch](./README-de_DE.md)
+* [Tiếng Việt](./README-vi.md)
+* [Українська мова](./README-ua_UA.md)
+* [Português Brasil](./README_pt_BR.md)
____________
From 90c6718ce75c1ec8da94e0b60c134e0749183ca1 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 17:12:55 +0200
Subject: [PATCH 104/881] Update README_AR.md
---
README_AR.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README_AR.md b/README_AR.md
index 57753fd2..3a65247f 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -27,8 +27,10 @@
* [Українська мова](./README-ua_UA.md)
* [Português Brasil](./README_pt_BR.md)
+
____________
+
1. ماهو الناتج ؟
```javascript
From 2da26a0cec170e24f9d859c76c57ec964616194d Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 17:43:23 +0200
Subject: [PATCH 105/881] Update README_AR.md
---
README_AR.md | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index 3a65247f..7df33b9c 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -1207,7 +1207,7 @@ console.log(numbers);
الجواب هو الخيار الأول : A
-النطاق أو الblock `catch`يستقبل ال arguemnt الذي يساوي `x`, هذا ليس نفس القيمة `x` هندما قمنا بتمرير الarguments, هذا المتغير `x` هو متغير block-scoped, أي يتم التعامل معه أو مناداته فقط بداخل الblock الذي تم تعريفه به.
+النطاق أو الblock `catch`يستقبل ال arguemnt الذي يساوي `x`, هذا ليس نفس القيمة `x` عندما قمنا بتمرير الarguments, هذا المتغير `x` هو متغير block-scoped, أي يتم التعامل معه أو مناداته فقط بداخل الblock الذي تم تعريفه به.
لاحقا, قمنا بضبط القيمة `1` لهذا المتغير من نوع block-scoped, وقمنا أيضا بضبط قيمة للمتغير `y`. الآن نحن نقوم بطباعة قيمة المتغير الذي من نوع block-scoped و الذي هو `x` عن طريق الlog, و الذي هو يساوي `1`.
@@ -1264,7 +1264,7 @@ console.log(numbers);
`[1, 2]` هي القيمة المبدئية.هذه القيمة هي التي بدأنا بها, و هي القيمة الأولى ل `acc`. أثناء الدورة الأولى`acc` تساوي `[1,2]` و `cur` تساوي `[0, 1]`, عندما نقوم بدمجهما سويا عن طريق concat يصبح لدينا الناتج `[1, 2, 0, 1]`.
-إذاً, `[1, 2, 0, 1]` هي `acc` و `[2, 3]` هي `cur`. نقوم بدمجهما سويةو نتحصل على `[1, 2, 0, 1, 2, 3]`.
+إذاً, `[1, 2, 0, 1]` هي `acc` و `[2, 3]` هي `cur`. نقوم بدمجهما سوية و نتحصل على `[1, 2, 0, 1, 2, 3]`.
@@ -1316,7 +1316,7 @@ console.log(numbers);
---
-42. ماهو الذي تقوم الدالة `setInterval` بإرجاع في المتصفح؟
+42. ماهو الذي تقوم الدالة `setInterval` بإرجاعه في المتصفح؟
```javascript
@@ -1324,13 +1324,13 @@ setInterval(() => console.log("Hi"), 1000);
```
-- A: فريد id
+فريد id - A
-- B: قيمة ال milliseconds محددة.
+قيمة ال milliseconds محددة. - B
-- C: الدالة التي تم تمريرها
+ C - الدالة التي تم تمريرها
-- D: `undefined`
+`undefined` - D
@@ -1339,7 +1339,7 @@ setInterval(() => console.log("Hi"), 1000);
الجواب هو الخيار الأول: A
-تقوم بإرجاع ال id الفريد, هذا الid يمكن استخدامه لكي يقوم بتصفير عداد الفترات المفصلة عن طريق استخدام الدالة `clearInterval()`
+تقوم بإرجاع ال id الفريد, هذا الid يمكن استخدامه لكي يقوم بتصفير عداد الفترات المفصلة أي الinterval عن طريق استخدام الدالة `clearInterval()`
@@ -1362,7 +1362,7 @@ setInterval(() => console.log("Hi"), 1000);
الجواب هو الخيار الأول: A
-الstring هي تكرارية, و عملية الspread (...) تقوم بتحويل اي حرف ينتمي الى فئة تكرارية الى عنصر منفرد واحد.
+الstring هي تكرارية, و عملية الspread (...) تقوم بتحويل اي حرف تم فيه تنفيذ فئة تكرارية الى عنصر منفرد واحد.
@@ -1393,7 +1393,7 @@ console.log(gen.next().value);
الجواب هو الخيار الثالث: C
-الدوال العادية ليس بإمكانها ان تتوقف في وسط التنفيذ بعد أن يتم مناداتها, و لكن الدوال من نوع generator من الممكن أن يتم ايقافها وسط التنفيذ, و لاحقا يتم مواصلة تنفيذها من حيث المكان الذي توقفت به. في كل مرة تواجه فيها الدالة من نوع generator الكلمة المفتاحية `yield`, فإن الدالة تخضع أو تستسلم للقيمة المحددة بعدها. مع ملاحظة أن الدالة من نوع generator في هذه الحالة, لاتقوم بإرجاع القيمة, يل تخضع لتلك القيمة.
+الدوال العادية ليس بإمكانها ان تتوقف في وسط التنفيذ بعد أن يتم مناداتها, و لكن الدوال من نوع generator من الممكن أن يتم ايقافها وسط التنفيذ, و لاحقا يتم مواصلة تنفيذها من حيث المكان الذي توقفت به. في كل مرة تواجه فيها الدالة من نوع generator الكلمة المفتاحية `yield`, فإن الدالة تخضع أو تستسلم للقيمة المحددة بعدها. مع ملاحظة أن الدالة من نوع generator في هذه الحالة, لاتقوم بإرجاع القيمة, بل تخضع لتلك القيمة.
أولا, نقوم بإنشاء الدالة من نوع generator مع وجود المتغير `i` مساوي ل `10`. نقوم بمناداة الدالةمن نوع generator باستخدام الدالة `next()`. في المرة الأولى التي ننادي فيها الدالة من نوع generator, فإن ال `i` تساوي `10`. هي تواجه الكلمة المفتاحية `yield`, فتخضع لقيمة ال `i`. الدالة generator في هذه اللحظة تم توقيفها مؤقتا, و القيمة `10` تم طباعتها عن طريق log.
@@ -1496,7 +1496,7 @@ for (const item in person) {
الإجابة
-#### Answer: B
+الجواب هو الخيار الثاني: B
بإستخدام `for-in` التكرارية, بامكاننا أن نصل الى جميع المفاتيح التي تخص object معين. في هذه الحالة `name` و `age`. ماوراء الكواليس, مفاتيح ال objects هي عبارة عن strings (إذا لم تكن هذه المفاتيح عبارة عن symbol), في أي حلقة من الحلقات التكرارية, نقوم بضبط القيمة `item`مساوية للمفتاح الحالي الذي هي تتكرر فيه اوعنده. أولا `item` تساوي `name`, و يتم طباعتها عن طريق الlog, ثم `item` تساوي `age` و التي ايضا تم طباعتها عن طريق الlog.
@@ -1523,7 +1523,6 @@ console.log(3 + 4 + "5");
Operator associativity او ترابطية العامل هي الترتيب أو التسلسل الذي يقيم به الcompiler ال expressions, ف هو إما أن يكون من اليسار الى اليمين أو من اليمين الى اليسار. هذا يحدث فقط إذا كان جميع الoperators لديها نفس الأسبقية. لدينا فقط نوع واحد من الoperator ألا و هو `+`. بالإضافة الى التالي, الترابطية هي من اليسار الى اليمين.
-`3 + 4` gets evaluated first. This results in the number `7`.
`3 + 4` يتم تقييمها أولا. هذا مايعطينا الناتج الذي هو عبارة عن الرقم `7`.
`7 + '5'` تقوم بإرجاع الناتج `"75"` بسبب عملية ال coercion وهي العمليةالتي تقوم بالتحويل من نوع الى آخر, لغة الجافاسكريبت تقوم بتحويل الرقم `7` الى النوع string, أنظرالى السؤال رقم 15 في الأعلى. بإمكاننا عمل concatenate لمتغيرين من النوع string بإستخدام العملية `+`. `"7" + "5"` سترجع الناتج `"75"`.
@@ -1581,7 +1580,7 @@ const num = parseInt("7*6", 10);
عندما يتم عمل mapping لل array, فإن قيمة `num` ستساوي قيمة العنصر الذي يتم حاليا المرور به, فكما نعرف أن الmapping يدور على جميع عناصر الarray. في هذه الحالة, العناصر عبارة عن أرقام, لهذا فإن شرط ال if statement `typeof num === "number"` يقوم بإرجاع `true`. دالة map تقوم بإنشاء array جديدة, و إدخال القيم المرجعة من الدالة في هذه الarray.
-ولكن, لا نقوم بإرجاع قيمة. عندما لا نقوم بإرجاع قيمة من الدالة, فإن الدالة تقوم بإرجاع `undefined`. لكل عنصرٍ في الarray, فإن نطاق الدالة يتم مناداته, لهذا لأي عنصر نقوم بإرجاع `undefined`.
+ولكن, لا نقوم بإرجاع قيمة. عندما لا نقوم بإرجاع قيمة من الدالة, فإن الدالة تقوم بإرجاع `undefined`. لكل عنصرٍ في الarray, فإن نطاق الدالة او نعني الfunction block يتم مناداته, لهذا لأي عنصر نقوم بإرجاع `undefined`.
@@ -1654,9 +1653,9 @@ sayHi();
الجواب هو الخيار الرابع: D
-مع عبارة `throw` , بإمكاننا إنشاء errors حسب الطلب, أي ليست كا الإخطاء العامة في اللغة, بإستخدام هذه العبارة بإمكانك أن تضع exception, الexception يمكن أن يكون : string, a number, a boolean or an object. في هذه الحالة, الexcption لدينا هو ال string `'Hello world'`.
+مع عبارة `throw` , بإمكاننا إنشاء errors حسب الطلب, أي ليست كا الإخطاء العامة في اللغة, بإستخدام هذه العبارة بإمكانك أن تضع exception, الexception يمكن أن يكون : string, number, boolean أو object. في هذه الحالة, الexcption لدينا هو ال string `'Hello world'`.
-مع عبارة `catch`, بإمكاننا ان نحدد ما الذي يتوجب فعله عندما يتم وضع أو إلقاء الexception في نطاق ال `try`. تم إلقاء أو وضع exception: الstring `'Hello world'`. `e` الآن تساوي تلك تلك الstring,و هي التي نقوم بطباعتها عن طريق الlgo. هذا سيعطينا النتيجة `'Oh an error: Hello world'`.
+مع عبارة `catch`, بإمكاننا ان نحدد ما الذي يتوجب فعله عندما يتم وضع أو إلقاء الexception في نطاق ال `try`. تم إلقاء أو وضع exception: الstring `'Hello world'`. `e` الآن تساوي تلك الstring,log. هذا سيعطينا النتيجة `'Oh an error: Hello world'`.
@@ -1680,12 +1679,12 @@ console.log(myCar.make);
- C: `ReferenceError`
- D: `TypeError`
-الإجابةAnswer
+الإجابة
الجواب هو الخيار الثاني: B
-عندما تقوم بإرجاع خاصية, فإن قيمة هذه الخاصية هي تساوي القيمة المرجعة, ليس القيمة التي تم ضبطها في دالة الconstructor. نقوم بإرجاع الstring `"Maserati"`, لذا فإن `myCar.make` تساوي `"Maserati"`.
+عندما تقوم بإرجاع خاصية, فإن قيمة هذه الخاصية هي تساوي القيمة المرجعة, ليس القيمة التي تم ضبطها في دالة الconstructor. نقوم بإرجاع ال string `"Maserati"`, لذا فإن `myCar.make` تساوي `"Maserati"`.
@@ -1722,7 +1721,8 @@ let x = y;
```
-عندما نقوم بضبط قيمة `y` لكي تساوي `10`, فنحن فعليا نقوم بإضافة الخاصية `y` للglopal object. (`window` في المتصفح, `global` في Node). في المتصفح, `window.y` الآن تساوي `10`.
+
+عندما نقوم بضبط قيمة`y` لكي تساوي `10`, فنحن فعليا نقوم بإضافة الخاصية `y` للglopal object. (`window` في المتصفح, `global` في Node). في المتصفح, `window.y` الآن تساوي `10`.
ثم, عندما نقوم بتعريف المتغير `x` بالقيمة `y` و التي هي في الحقيقة تساوي `10`. المتغيرات التي يتم تعريفها بالكلمة المفتاحية `let`هي متغيرات block scoped, أي يتم التعامل معها في النطاق الذي تم تعريفها فيه فقط, الدالة المناداة حاليا في هذه الحالة أي immediately-invoked function (IIFE). عندما نقوم بإستخدام العملية `typeof`, فإن المعامل `x` ليس معرف, نحن نحاول الوصول الى `x` خارج النطاق الذي تم تعريفه بها. هذا يعني أن `x` ليست معرفة. المتغيرات التي لم يتم وضع قيمة لها أو لم يتم تعريفها هي من النوع `"undefined"`. `console.log(typeof x)` تقوم بإرجاع `"undefined"`.
From e22f060a508c4365f6d333217926c54f6abe4650 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 17:48:29 +0200
Subject: [PATCH 106/881] Update README_AR.md
---
README_AR.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index 7df33b9c..07650141 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -1089,7 +1089,7 @@ console.log(typeof sayHi());
---
-35. أي هذه القيم هي قيم قابلة للخطأ؟
+35. أي هذه القيم هي قيم خطئية؟
```javascript
0;
@@ -1110,7 +1110,7 @@ undefined;
الجواب هو الخيار الأول : A
-لدينا فقط ستة قيم قابلة للخطأ:
+لدينا فقط ستة قيم خطئية:
- `undefined`
- `null`
@@ -1119,7 +1119,7 @@ undefined;
- `''` (empty string)
- `false`
-Function constructors, مثل `new Number` و `new Boolean` هي قيم قابلة للصواب.
+Function constructors, مثل `new Number` و `new Boolean` هي قيم صحيحية.
From 6606eafb5bd5188c929229024859b4bc1cf6e413 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 17:53:05 +0200
Subject: [PATCH 107/881] Update README_AR.md
---
README_AR.md | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index 07650141..82c5c8d6 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -1316,6 +1316,7 @@ console.log(numbers);
---
+
42. ماهو الذي تقوم الدالة `setInterval` بإرجاعه في المتصفح؟
@@ -1324,9 +1325,11 @@ setInterval(() => console.log("Hi"), 1000);
```
-فريد id - A
-
-قيمة ال milliseconds محددة. - B
+
+ A- id فريد
+
+
+ B - قيمة محددة لل milliseconds
C - الدالة التي تم تمريرها
From a89c46a7e75b920221b9756328bee7fde018a185 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 17:54:51 +0200
Subject: [PATCH 108/881] Update README_AR.md
---
README_AR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_AR.md b/README_AR.md
index 82c5c8d6..9a2140c7 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -1326,7 +1326,7 @@ setInterval(() => console.log("Hi"), 1000);
- A- id فريد
+A - id فريد
B - قيمة محددة لل milliseconds
From 37dce1098d76675b9993171f2462ebb922033262 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 17:56:26 +0200
Subject: [PATCH 109/881] Update README_AR.md
---
README_AR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_AR.md b/README_AR.md
index 9a2140c7..183efb8f 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -1326,7 +1326,7 @@ setInterval(() => console.log("Hi"), 1000);
-A - id فريد
+A - فريد id
B - قيمة محددة لل milliseconds
From a462a17e3edcc598c2c43d102fa45d8eaef80515 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 17:59:06 +0200
Subject: [PATCH 110/881] Update README_AR.md
---
README_AR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_AR.md b/README_AR.md
index 183efb8f..8c4f822a 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -1326,7 +1326,7 @@ setInterval(() => console.log("Hi"), 1000);
-A - فريد id
+A - رقم فريد أو متفرد id
B - قيمة محددة لل milliseconds
From dd41301522b0a0c22dbcff2b38befac04aba735a Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Fri, 28 Jun 2019 18:03:10 +0200
Subject: [PATCH 111/881] Update README_AR.md
---
README_AR.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README_AR.md b/README_AR.md
index 8c4f822a..f8e48560 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -391,6 +391,7 @@ Person.prototype.getFullName = function() {
```
+
اذا استطعنا جعل `member.getFullName()` تعمل. لماذا ستكون ذات فائدة؟ فلنفترض أننا أضفنا هذه الmethod للconstructor نفسها. ربما ليس أي instance من `Person` تحتاج الى هذه ال method. بهذه الطريقة سنقوم بإستهلاك مساحة كبيرة من الذاكرة, بما أنهم سيظلون يحتفظون ب هذه الخاصية, و التي بدورها ستقوم بحجز مساحة في الذاكرة لأي instance. لذا من الأفضل أن نقوم بإضافتهاالى الprototype, بهذه الطريقة ستقوم بحجز مكان واحد فقط في الذاكرة, و لكنها متاحة للكل للوصول إليها.
@@ -533,7 +534,7 @@ console.log(number);
1. تقوم بزيادة القيمة(number الآن تساوي `2`)
2. تقوم بإٍرجاع القيمة (هذه ترجع `2`)
-هذايقوم بإرجاع `0 2 2`.
+هذا يقوم بإرجاع `0 2 2`.
From f1bf6d419380ee098ef48c5c1f4a826ae333da97 Mon Sep 17 00:00:00 2001
From: Lydia
Date: Sat, 29 Jun 2019 13:58:59 +0200
Subject: [PATCH 112/881] Add questions 55 to 63
---
README.md | 299 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 299 insertions(+)
diff --git a/README.md b/README.md
index 52c948f6..b886f849 100644
--- a/README.md
+++ b/README.md
@@ -1655,3 +1655,302 @@ However, we created a global variable `y` when setting `y` equal to `10`. This v
+
+---
+
+###### 55. What's the output?
+
+```javascript
+class Dog {
+ constructor(name) {
+ this.name = name;
+ }
+}
+
+Dog.prototype.bark = function() {
+ console.log(`Woof I am ${this.name}`);
+};
+
+const pet = new Dog("Mara");
+
+pet.bark();
+
+delete Dog.prototype.bark;
+
+pet.bark();
+```
+
+- A: `"Woof I am Mara"`, `TypeError`
+- B: `"Woof I am Mara"`,`"Woof I am Mara"`
+- C: `"Woof I am Mara"`, `undefined`
+- D: `TypeError`, `TypeError`
+
+Answer
+
+
+#### Answer: A
+
+We can delete properties from objects using the `delete` keyword, also on the prototype. By deleting a property on the prototype, it is not available anymore in the prototype chain. In this case, the `bark` function is not available anymore on the prototype after `delete Dog.prototype.bark`, yet we still try to access it.
+
+When we try to invoke something that is not a function, a `TypeError` is thrown. In this case `TypeError: pet.bark is not a function`, since `pet.bark` is `undefined`.
+
+
+
+
+---
+
+###### 56. What's the output?
+
+```javascript
+const set = new Set([1, 1, 2, 3, 4]);
+
+console.log(set);
+```
+
+- A: `[1, 1, 2, 3, 4]`
+- B: `[1, 2, 3, 4]`
+- C: `{1, 1, 2, 3, 4}`
+- D: `{1, 2, 3, 4}`
+
+Answer
+
+
+#### Answer: D
+
+The `Set` object is a collection of _unique_ values: a value can only occur once in a set.
+
+We passed the iterable `[1, 1, 2, 3, 4]` with a duplicate value `1`. Since we cannot have two of the same values in a set, one of them is removed. This results in `{1, 2, 3, 4}`.
+
+
+
+
+---
+
+###### 57. What's the output?
+
+```javascript
+// counter.js
+let counter = 10;
+export default counter;
+```
+
+```javascript
+// index.js
+import myCounter from "./counter";
+
+myCounter += 1;
+
+console.log(myCounter);
+```
+
+- A: `10`
+- B: `11`
+- C: `Error`
+- D: `NaN`
+
+Answer
+
+
+#### Answer: C
+
+An imported module is _read-only_: you cannot modify the imported module. Only the module that exports them can change its value.
+
+When we try to increment the value of `myCounter`, it throws an error: `myCounter` is read-only and cannot be modified.
+
+
+
+
+---
+
+###### 58. What's the output?
+
+```javascript
+const name = "Lydia";
+age = 21;
+
+console.log(delete name);
+console.log(delete age);
+```
+
+- A: `false`, `true`
+- B: `"Lydia"`, `21`
+- C: `true`, `true`
+- D: `undefined`, `undefined`
+
+Answer
+
+
+#### Answer: A
+
+The `delete` operator returns a boolena value: `true` on a successful deletion, else it'll return `false`. However, variables declared with the `var`, `const` or `let` keyword cannot be deleted using the `delete` operator.
+
+The `name` variable was declared with a `const` keyword, so its deletion is not successful: `false` is returned. When we set `age` equal to `21`, we actually added a property called `age` to the global object. You can successfully delete properties from objects this way, also the global object, so `delete age` returns `true`.
+
+
+
+
+---
+
+###### 59. What's the output?
+
+```javascript
+const numbers = [1, 2, 3, 4, 5];
+const [y] = numberes;
+
+console.log(y);
+```
+
+- A: `[[1, 2, 3, 4, 5]]`
+- B: `[1, 2, 3, 4, 5]`
+- C: `1`
+- D: `[1]`
+
+Answer
+
+
+#### Answer: C
+
+We can unpack values from arrays or properties from objects through destructing. For example:
+
+```javascript
+[a, b] = [1, 2];
+```
+
+
+
+The value of `a` is now `1`, and the value of `b` is now `2`. What we actually did in the question, is:
+
+```javascript
+[y] = [1, 2, 3, 4, 5];
+```
+
+
+
+This means that the value of `y` is equal to the first value in the array, which is the number `1`. When we log `y`, `1` is returned.
+
+
+
+
+---
+
+###### 60. What's the output?
+
+```javascript
+const user = { name: "Lydia", age: 21 };
+const admin = { admin: true, ...user };
+
+console.log(admin);
+```
+
+- A: `{ admin: true, user: { name: "Lydia", age: 21 } }`
+- B: `{ admin: true, name: "Lydia", age: 21 }`
+- C: `{ admin: true, user: ["Lydia", 21] }`
+- D: `{ admin: true }`
+
+Answer
+
+
+#### Answer: B
+
+It's possible to combine objects using the spread operator `...`. It lets you create copies of the key/value pairs of one object, and add them to another object. In this case, we create copies of the `user` object, and add them to the `admin` object. The `admin` object now contains the copied key/value pairs, which results in `{ admin: true, name: "Lydia", age: 21 }`.
+
+
+
+
+---
+
+###### 61. What's the output?
+
+```javascript
+const person = { name: "Lydia" };
+
+Object.defineProperty(person, "age", { value: 21 });
+
+console.log(person);
+console.log(Object.keys(person));
+```
+
+- A: `{ name: "Lydia", age: 21 }`, `["name", "age"]`
+- B: `{ name: "Lydia", age: 21 }`, `["name"]`
+- C: `{ name: "Lydia"}`, `["name", "age"]`
+- D: `{ name: "Lydia"}`, `["age"]`
+
+Answer
+
+
+#### Answer: B
+
+With the `defineProperty` method, we can add new properties to an object, or modify existing ones. When we add a property to an object using the `defineProperty` method, they are by default _not enumerable_. The `Object.keys` method returns all _enumerable_ property names from an object, in this case only `"name"`.
+
+Properties added using the `defineProperty` method are immutable by default. You can override this behavior using the `writable`, `configurable` and `enumerable` properties. This way, the `defineProperty` method gives you a lot more control over the properties you're adding to an object.
+
+
+
+
+---
+
+###### 62. What's the output?
+
+```javascript
+const settings = {
+ username: "lydiahallie",
+ level: 19,
+ health: 90
+};
+
+const data = JSON.stringify(settings, ["level", "health"]);
+console.log(data);
+```
+
+- A: `"{"level":19, "health":90}"`
+- B: `"{"username": "lydiahallie"}"`
+- C: `"["level", "health"]"`
+- D: `"{"username": "lydiahallie", "level":19, "health":90}"`
+
+Answer
+
+
+#### Answer: A
+
+The second argument of `JSON.stringify` is the _replacer_. The replacer can either be a function or an array, and lets you control what and how the values should be stringified.
+
+If the replacer is an _array_, only the properties which names are included in the array will be added to the JSON string. In this case, only the properies with the names `"level"` and `"health"` are included, `"username"` is excluded. `data` is now equal to `"{"level":19, "health":90}"`.
+
+If the replacer is a _function_, this function gets called on every property in the object you're stringifying. The value returned from this function will be the value of the property when it's added to the JSON string. If the value is `undefined`, this property is excluded from the JSON string.
+
+
+
+
+---
+
+###### 63. What's the output?
+
+```javascript
+let num = 10;
+
+const increaseNumber = () => num++;
+const increasePassedNumber = number => number++;
+
+const num1 = increaseNumber();
+const num2 = increasePassedNumber(num1);
+
+console.log(num1);
+console.log(num2);
+```
+
+- A: `10`, `10`
+- B: `10`, `11`
+- C: `11`, `11`
+- D: `11`, `12`
+
+Answer
+
+
+#### Answer: A
+
+The unary operator `++` _first returns_ the value of the operand, _then increments_ the value of the operand. The value of `num1` is `10`, since the `increaseNumber` function first returns the value of `num`, which is `10`, and only increments the value of `num` afterwards.
+
+`num2` is `10`, since we passed `num1` to the `increasePassedNumber`. `number` is equal to `10`(the value of `num1`. Again, the unary operator `++` _first returns_ the value of the operand, _then increments_ the value of the operand. The value of `number` is `10`, so `num2` is equal to `10`.
+
+
+
From b9e7651e13f07c5a8a3b2cb1b9d490fc635b43e6 Mon Sep 17 00:00:00 2001
From: Lydia
Date: Sat, 29 Jun 2019 14:15:32 +0200
Subject: [PATCH 113/881] Fix question 51
---
README.md | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index f68f5f09..1bb924fc 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,6 @@ List of available languages:
* [中文版本](./README-zh_CN.md)
* [Versión en español](./README-ES.md)
* [日本語](./README-ja_JA.md)
-* [한국어](./README-ko_KR.md)
* [Русский](./README_ru-RU.md)
* [Western Balkan](./README-bs_BS.md)
* [Deutsch](./README-de_DE.md)
@@ -1521,7 +1520,7 @@ However, we don’t return a value. When we don’t return a value from the func
```javascript
function getInfo(member, year) {
member.name = "Lydia";
- year = 1998;
+ year = "1998";
}
const person = { name: "Sarah" };
@@ -1573,9 +1572,9 @@ sayHi();
```
- A: `"It worked! Hello world!"`
-- B: `"Oh no an error: undefined"`
+- B: `"Oh no an error: undefined`
- C: `SyntaxError: can only throw Error objects`
-- D: `"Oh no an error! Hello world!"`
+- D: `"Oh no an error: Hello world!`
Answer
From 3004132b96e84335c9fe68bcaecc0cc157b838ad Mon Sep 17 00:00:00 2001
From: Lydia
Date: Sat, 29 Jun 2019 14:20:01 +0200
Subject: [PATCH 114/881] Fix question 10
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 1bb924fc..e6005514 100644
--- a/README.md
+++ b/README.md
@@ -320,7 +320,7 @@ bark.animal = "dog";
- A: Nothing, this is totally fine!
- B: `SyntaxError`. You cannot add properties to a function this way.
-- C: `undefined`
+- C: `"Woof"` gets logged.
- D: `ReferenceError`
Answer
From c9a015243500cb6400dbebe3aef5522e0fbb6ab8 Mon Sep 17 00:00:00 2001
From: Lydia
Date: Sat, 29 Jun 2019 14:23:22 +0200
Subject: [PATCH 115/881] Fix question 3
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index e6005514..d684f98f 100644
--- a/README.md
+++ b/README.md
@@ -92,8 +92,8 @@ const shape = {
perimeter: () => 2 * Math.PI * this.radius
};
-shape.diameter();
-shape.perimeter();
+console.log(shape.diameter());
+console.log(shape.perimeter());
```
- A: `20` and `62.83185307179586`
From 319e3f2375269e8b504f9efe323f6d6e16e5cea3 Mon Sep 17 00:00:00 2001
From: Lydia Hallie
Date: Sat, 29 Jun 2019 15:15:35 +0200
Subject: [PATCH 116/881] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index d684f98f..af9784d3 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
I post daily multiple choice JavaScript questions on my [Instagram](https://www.instagram.com/theavocoder), which I'll also post here!
-From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle: :rocket: I update this repo weekly with new questions. Last update: June 21st
+From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle: :rocket: I update this repo weekly with new questions. Last update: June 29th
The answers are in the collapsed sections below the questions, simply click on them to expand it. Good luck :heart:
From 3ac8f92809b2c3b2d0121b3ad29d8811627d1de3 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Sat, 29 Jun 2019 15:35:10 +0200
Subject: [PATCH 117/881] Update README.md
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 916fa133..16379695 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,8 @@ From basic to advanced: test how well you know JavaScript, refresh your knowledg
The answers are in the collapsed sections below the questions, simply click on them to expand it. Good luck :heart:
+
+[العربية](https://github.com/SaraAli26/javascript-questions/blob/master/README_AR.md)
[中文版本](./README-zh_CN.md)
[Русский](./README_ru-RU.md)
[Western Balkan](./README-bs_BS.md)
From 5d8e349e56900eb8cf7f97c9326ec61dcbcd1acf Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Sat, 29 Jun 2019 15:38:01 +0200
Subject: [PATCH 118/881] link to Arabic added to introduction
---
README.md | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 16379695..91a7e32f 100644
--- a/README.md
+++ b/README.md
@@ -6,13 +6,18 @@ From basic to advanced: test how well you know JavaScript, refresh your knowledg
The answers are in the collapsed sections below the questions, simply click on them to expand it. Good luck :heart:
-
-[العربية](https://github.com/SaraAli26/javascript-questions/blob/master/README_AR.md)
-[中文版本](./README-zh_CN.md)
-[Русский](./README_ru-RU.md)
-[Western Balkan](./README-bs_BS.md)
-[Deutsch](./README-de_DE.md)
-[Tiếng Việt](./README-vi.md)
+
+* [English](./README.md)
+* [中文版本](./README-zh_CN.md)
+* [Versión en español](./README-ES.md)
+* [日本語](./README-ja_JA.md)
+* [Русский](./README_ru-RU.md)
+* [Western Balkan](./README-bs_BS.md)
+* [Deutsch](./README-de_DE.md)
+* [Tiếng Việt](./README-vi.md)
+* [Українська мова](./README-ua_UA.md)
+* [Português Brasil](./README_pt_BR.md)
+* [العربية](https://github.com/SaraAli26/javascript-questions/blob/master/README_AR.md)
---
From 67405aaf884922def99e7384982c4fa537309260 Mon Sep 17 00:00:00 2001
From: Lydia Hallie
Date: Sat, 29 Jun 2019 15:41:48 +0200
Subject: [PATCH 119/881] Update README.md
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index af9784d3..d4fffadb 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,7 @@ List of available languages:
* [中文版本](./README-zh_CN.md)
* [Versión en español](./README-ES.md)
* [日本語](./README-ja_JA.md)
+* [한국어](./README-ko_KR.md)
* [Русский](./README_ru-RU.md)
* [Western Balkan](./README-bs_BS.md)
* [Deutsch](./README-de_DE.md)
From e12b10b0790c66a616e688ae32ff0e02d0ae4e04 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Sat, 29 Jun 2019 15:54:37 +0200
Subject: [PATCH 120/881] Update README.md
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index d1ebb7d0..f30cc8f6 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,8 @@ List of available languages:
* [Tiếng Việt](./README-vi.md)
* [Українська мова](./README-ua_UA.md)
* [Português Brasil](./README_pt_BR.md)
-* [العربية](https://github.com/SaraAli26/javascript-questions/blob/master/README_AR.md)
+* [العربية](./README_AR.md)
+
---
From 73f516977aee349402945d79274736fff6f01e0b Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Sat, 29 Jun 2019 16:08:42 +0200
Subject: [PATCH 121/881] Update README_AR.md
---
README_AR.md | 2 --
1 file changed, 2 deletions(-)
diff --git a/README_AR.md b/README_AR.md
index f8e48560..05d51b95 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -9,8 +9,6 @@
أقوم بتحديث هذا المستودع أسبوعيا بإضافة المزيد من الأسئلة. :muscle: :rocket:
-آخر تحديث: 21 يونيو
-
الأجوبة توجد في الجزء المطوي بالأسفل أدناه تحت كل سؤال على حدة, فقط قم بالضغط على كلمة الإجابة لكي تحصل على الإجابة, حظا موفقا :heart:
From d6a5a2e2314c71d52071278dfe8aa7676d91a381 Mon Sep 17 00:00:00 2001
From: kimdanah
Date: Sun, 30 Jun 2019 02:28:22 +0900
Subject: [PATCH 122/881] Improve accuracy of the translation.
---
README-ko_KR.md | 97 ++++++++++++++++++++++++-------------------------
1 file changed, 47 insertions(+), 50 deletions(-)
diff --git a/README-ko_KR.md b/README-ko_KR.md
index 7719f3c2..0b926df0 100644
--- a/README-ko_KR.md
+++ b/README-ko_KR.md
@@ -2,7 +2,7 @@
JavaScript 에 관한 객관식 문제를 [Instagram](https://www.instagram.com/theavocoder)에 매일 게시하고 있어요, 물론 여기에도 게시할 거예요!
-초급부터 고급까지: JavaScript를 얼마나 잘 알고 있는지 테스트하거나, 지식을 조금 깊게 하거나, 코딩 면접을 준비하세요! :muscle: :rocket: 이 기록을 매주 새로운 질문으로 업데이트해요. 마지막 업데이트: 6월 21일
+초급부터 고급까지: JavaScript를 얼마나 잘 알고 있는지 테스트하거나, 지식을 조금 더 새롭게 하거나, 코딩 면접을 준비하세요! :muscle: :rocket: 이 기록을 매주 새로운 질문으로 업데이트해요. 마지막 업데이트: 6월 29일
정답은 질문 아래 접힌 부분에 있어요, 그냥 클릭하면 펼칠 수 있어요. 행운을 빌어요 :heart:
@@ -42,9 +42,9 @@ sayHi();
#### 정답: D
-함수 내에서, 우선 `var`키워드를 사용해 `name`변수를 선언해요. 이것은 변수가 정의되어 있는 행에 실제로 도달할 때까지, 변수는 `undefined`의 기본값으로 호이스팅 되(생성단계에 메모리 공간이 설정됨)는 것을 의미해요. `name` 변수를 출력하려는 줄에서 아직 변수를 정의하고 있지 않기 때문에, `undefined`값을 유지하고 있어요.
+함수 내에서, 우선 `var`키워드를 사용해 `name`변수를 선언해요. 이것은 변수가 정의되어 있는 행에 실제로 도달할 때까지, `undefined`의 기본값으로 호이스팅 되(생성단계에 메모리 공간이 설정)는 것을 의미해요. `name` 변수를 출력하려는 줄에서 아직 변수를 정의하고 있지 않기 때문에, `undefined`값을 유지하고 있어요.
-`let`키워드(그리고 `const`)를 가지는 변수들은, `var`와는 달리, 호이스팅되지만 초기화되지 않아요. 그것들을 선언(초기화)하는 줄 전에는 접근할 수 없어요. 이것은 "일시적 사각지대"라고 불려요. 선언되기 전에 변수에 접근하려고 하면, JavaScript는 `ReferenceError`를 던져요.
+`let`키워드(그리고 `const`)를 가지는 변수들은, `var`와는 달리, 호이스팅되지만 초기화되지 않아요. 그것들을 선언(초기화)하는 줄 전에는 접근할 수 없어요. 이것은 "일시적 사각지대"라고 불려요. 선언되기 전 변수에 접근하려고 하면, JavaScript는 `ReferenceError`를 던져요.
@@ -72,7 +72,7 @@ for (let i = 0; i < 3; i++) {
#### 정답: C
-JavaScript의 이벤트 큐 때문에, `setTimeout`의 콜백 함수는 루프가 실행된 _후에_ 호출되어요. 첫 번째의 루프 변수 `i`는 `var`키워드를 사용해 선언되어 있으므로, 이 값은 전역 변수가 되어요. 루프 동안, 단항 연산자 `++`를 사용하여, 매번 `i`의 값을 `1`씩 증가했어요. `setTimeout`콜백 함수가 호출되기까지, 첫 번째 예에서 `i`는 `3`과 같아요.
+JavaScript의 이벤트 큐 때문에, `setTimeout`의 콜백 함수는 루프가 실행된 _후에_ 호출돼요. 첫 번째의 루프 변수 `i`는 `var`키워드를 사용해 선언되어 있기 때문에, 이 값은 전역 변수가 돼요. 루프 동안, 단항 연산자 `++`를 사용하여, 매번 `i`의 값을 `1`씩 증가했어요. `setTimeout`콜백 함수가 호출되기까지, 첫 번째 예에서 `i`는 `3`이에요.
두 번째 루프에서, 변수 `i`는 `let`키워드를 사용해 선언되었어요: `let`(그리고 `const`)키워드로 선언된 변수는 블록 범위예요(블록은 `{ }` 사이의 모든 것). 각각의 반복 동안, `i`는 새로운 값을 가지고, 각각의 값은 루프 안쪽 범위에 있어요.
@@ -92,8 +92,8 @@ const shape = {
perimeter: () => 2 * Math.PI * this.radius
};
-shape.diameter();
-shape.perimeter();
+console.log(shape.diameter());
+console.log(shape.perimeter());
```
- A: `20` 그리고 `62.83185307179586`
@@ -108,9 +108,9 @@ shape.perimeter();
`diameter`의 값은 정규 함수인 반면, `perimeter`의 값은 화살표 함수라는 점을 유의하세요.
-화살표 함수에서는, 통상적인 함수와는 달리, `this`키워드는 현재 주위의 범위를 참조해요! 이것은 `perimeter`를 부르면, shape 객체가 아닌, 그 주위의 범위(예를 들면 window)를 참조하는 것을 의미해요.
+화살표 함수에서, `this`키워드는 통상적인 함수와는 다르게 현재 주위의 범위를 참조해요! 이것은 `perimeter`를 부르면, shape 객체가 아닌 그 주위의 범위(예를 들면 window)를 참조하는 것을 의미해요.
-그 객체에는 `radius`라는 값은 없어, `undefined`를 리턴해요.
+그 객체에는 `radius`라는 값은 없기 때문에 `undefined`를 리턴해요.
@@ -133,9 +133,9 @@ shape.perimeter();
#### 정답: A
-단항 더하기는 피연산자를 숫자로 변환하려 해요. `true`는 `1`, `false`은 `0`.
+단항 더하기는 피연산자를 숫자로 변환하려 시도 해요. `true`는 `1`이고, `false`은 `0`이에요.
-문자열 `'Lydia'`는 참 같은 값이에요. 실제로 물어보는 것은, "이 참 같은 값이 거짓 같은 값인가?"에요. 이것은 `false`을 리턴해요.
+문자열 `'Lydia'`는 참 같은 값이에요. 실제로는, "이 참 같은 값이 거짓 같은 값인가?"를 물어보고 있어요. 이것은 `false`을 리턴해요.
@@ -165,15 +165,13 @@ const mouse = {
#### 정답: A
-JavaScript에서, 모든 객체 키는 문자열이에요 (심볼이 아닌 한). 비록 그것을 문자열 _형_ 으로 입력하지 않아도, 항상 내부적으로 문자열로 변환되어요.
+JavaScript에서, 모든 객체 키는 문자열이에요 (심볼이 아닌 한). 비록 그것을 문자열 _형_ 으로 입력하지 않아도, 항상 내부적으로 문자열로 변환돼요.
-JavaScript는 문장을 해석(또는 박스 해제)해요. 대괄호 표기를 사용하면, 첫 번째 왼쪽 대괄호 `[`를 보고 오른쪽 대괄호 `]`를 찾을 때까지 진행해요. 그때, 그 문장을 평가할 거에요.
+JavaScript는 문장을 해석(또는 박스 해제)해요. 대괄호 표기를 사용하면, 첫 번째 열린 대괄호 `[`를 보고 닫힌 대괄호 `]`를 찾을 때까지 진행해요. 그때에 만, 그 문장을 평가할 거예요.
-`mouse[bird.size]`: 먼저 `bird.size`를 평가해요, 이것은 `"small"`이에요. `mouse["small"]` 은 `true`를 리턴해요.
+`mouse[bird.size]`: 먼저 `"small"`인 `bird.size`를 평가해요. `mouse["small"]` 은 `true`를 리턴해요.
-그러나, 닷 표기에서는, 이것은 발생하지 않아요, `mouse`는 `bird`라고 불리는 키를 가지고 있지 않아요 즉, `mouse.bird`는 `undefined`를 의미해요.
-
-또, 닷 표기를 사용해 `size`를 물어봐요. `mouse.bird.size`. `mouse.bird`는 `undefined`로, 실제로는 `undefined.size`를 물어보고 있어요. 이것은 유효하지 않기 때문에, `Cannot read property "size" of undefined`와 비슷한 에러를 던질 거예요.
+그러나, 닷 표기법에서, 이것은 발생하지 않아요, `mouse`는 `bird`라고 불리는 키를 가지고 있지 않아요. 즉, `mouse.bird`는 `undefined`를 의미해요. 그 후, 닷 표기법을 사용해 `size`를 물어봐요. `mouse.bird.size`. `mouse.bird`는 `undefined`로, 실제로는 `undefined.size`를 물어보고 있어요. 이것은 유효하지 않기 때문에, `Cannot read property "size" of undefined`와 비슷한 에러를 던질 거예요.
@@ -286,8 +284,8 @@ console.log(freddie.colorChange("orange"));
###### 9. 무엇이 출력 될까요?
```javascript
-let greeting;
-greetign = {}; // Typo!
+let greeting; // Typo!
+greetign = {};
console.log(greetign);
```
@@ -300,7 +298,7 @@ console.log(greetign);
#### 정답: A
-객체는 출력돼요, 전역 객체에 빈 객체를 방금 만들었기 때문이에요. `greeting`을 `greettign`으로 잘못 입력했을 경우, JS 인터프리터는 실제로 이것을 `global.greettign = {}` (또는 브라우저의 `window.greetign = {}`) 라고 간주해요.
+역 객체에 빈 객체를 방금 만들었기 때문에, 객체는 출력되요. `greeting`을 `greettign`으로 잘못 입력했을 경우, JS 인터프리터는 실제로 이것을 `global.greettign = {}` (또는 브라우저의 `window.greetign = {}`) 라고 간주해요.
이것을 피하기 위해서, `"use strict"`를 사용할 수 있어요. 이렇게 하면 변수를 어떤 것과 동일하게 설정하기 전에 변수를 선언했는지 확인할 수 있어요.
@@ -309,7 +307,7 @@ console.log(greetign);
---
-###### 10. 이것을 하면 어떻게 될까요?
+###### 10. 이렇게 하면 무슨 일이 생길까요?
```javascript
function bark() {
@@ -319,9 +317,9 @@ function bark() {
bark.animal = "dog";
```
-- A: 아무 일도 일어나지 않아요, 이건 완전히 괜찮아요!
+- A: 별일 없어요, 이건 완전히 괜찮아요!
- B: `SyntaxError` 이 방법으로 함수에 속성을 추가할 수 없어요.
-- C: `undefined`
+- C: `"Woof"`이 출력돼요.
- D: `ReferenceError`
정답
@@ -329,8 +327,7 @@ bark.animal = "dog";
#### 정답: A
-JavaScript에서는 가능해요, 함수는 객체이기 때문이에요!
-(윈시형 이외는 모두 객체)
+함수는 객체이기 때문에, 이건 JavaScript에서는 가능해요! (윈시형 이외는 모두 객체)
함수는 특별한 종류의 객체예요. 당신이 쓴 코드는 실제 함수가 아니에요. 함수는 속성을 가진 객체예요. 이 속성은 호출이 가능해요.
@@ -365,7 +362,7 @@ console.log(member.getFullName());
#### 정답: A
-보통의 객체처럼 생성자에는 속성을 추가할 수 없어요. 한 번에 모든 객체에 기능을 추가하고 싶다면, 프로토타입을 사용해야 해요. 그래서 이 경우에,
+생성자에는 보통의 객체처럼 속성을 추가할 수 없어요. 한 번에 모든 객체에 기능을 추가하고 싶다면, 프로토타입을 사용해야 해요. 그래서 이 경우에,
```js
Person.prototype.getFullName = function() {
@@ -373,7 +370,7 @@ Person.prototype.getFullName = function() {
};
```
-`member.getFullName()`은 작동해요. 이것은 왜 유익할까요? 이 메소드를 생성자 자체에 추가했다고 할게요. 아마도 모든 `Person` 인스턴스는 이 메소드를 필요로 하지 않을 수도 있어요. 그 경우 그들은 아직 속성을 갖고, 각각의 인스턴스를 위해 메모리 공간을 소비하기 때문에, 많은 메모리 공간을 낭비해요. 대신에, 프로토타입을 추가하는 것만으로, 메모리의 한 지점을 가지지만, 모든 것들은 그것에 접근 할 수 있어요.
+`member.getFullName()`은 작동해요. 이것은 왜 유익할까요? 이 메소드를 생성자 자체에 추가했다고 할게요. 아마도 모든 `Person` 인스턴스는 이 메소드를 필요로 하지 않을 수도 있어요. 그 경우 그들은 계속해서 속성을 갖고 있기 때문에, 각각의 인스턴스를 위한 메모리 공간을 소비하게 되어, 많은 메모리 공간을 낭비하게 될 거예요. 대신에, 프로토타입을 추가하는 것만으로, 메모리의 한 지점을 가지지만, 모든 것들은 그것에 접근 할 수 있어요.
@@ -405,9 +402,9 @@ console.log(sarah);
#### 정답: A
-`sarah`를 위해, `new`키워드를 사용하지 않았어요. `new`를 사용한 경우, 이것은 우리가 만든 새로운 빈 객체를 참조해요. 그러나, `new`를 추가하지 않으면 **전역변수**를 참조해요!
+`sarah`에게 `new`키워드를 사용하지 않았어요. `new`를 사용한 경우, 이것은 우리가 만든 새로운 빈 객체를 참조해요. 그러나, `new`를 추가하지 않으면 **전역변수**를 참조해요!
-`this.firstName`에 `"Sarah"`을 대입하고, `this.lastName`에 `"Smith"`을 대입했다고 말했었어요. (그렇지만) 우리는 실제로, `global.firstName = 'Sarah'` 그리고 `global.lastName = 'Smith'`를 정의해요. `sarah` 자체는 `undefined`로 남아있어요.
+`this.firstName`은 `"Sarah"`이고, `this.lastName`은 `"Smith"`이리고 말했었어요. (그렇지만) 우리는 실제로 한 일은 `global.firstName = 'Sarah'` 그리고 `global.lastName = 'Smith'`를 정의하는 것이에요. `sarah` 자체는 `undefined`로 남아있어요.
@@ -445,7 +442,7 @@ console.log(sarah);
#### 정답: B
-**기본 객체**를 제외한, 모든 객체는 프로토타입을 가져요. 기본 객체는 사용자에 의해 만들어지거나 `new`키워드를 사용하여 만들어져요. 기본 객체는 `.toString`와 같은 몇 개의 메소드와 속성에 접근할 수 있어요. 이것이 내장 JavaScript 메소드를 사용할 수 있는 이유죠! 이러한 모든 메소드는 프로토 타입에서 이용할 수 있어요. JavaScript가 당신의 객체를 직접 찾을 수 없더라도, 당신이 접근할 수 있도록, 프로토타입 체인으로 내려가서 찾을거에요.
+**기본 객체**를 제외한, 모든 객체는 프로토타입을 가져요. 기본 객체는 사용자에 의해 만들어지거나 `new`키워드를 사용하여 만들어져요. 기본 객체는 `.toString`와 같은 몇 개의 메소드와 속성에 접근할 수 있어요. 이것이 내장 JavaScript 메소드를 사용할 수 있는 이유죠! 이러한 모든 메소드는 프로토 타입에서 이용할 수 있어요. JavaScript가 당신의 객체를 직접 찾을 수 없더라도, 당신이 접근할 수 있도록 프로토타입 체인으로 내려가서 찾을거에요.
@@ -663,7 +660,7 @@ const sum = eval("10*10+5");
---
-###### 22. cool_secret에 몇시간 접근이 가능 할까요 ?
+###### 22. cool_secret에 몇 시간이나 접근이 가능할까요?
```javascript
sessionStorage.setItem("cool_secret", 123);
@@ -672,7 +669,7 @@ sessionStorage.setItem("cool_secret", 123);
- A: 영원히, 데이터는 사라지지 않아요.
- B: 사용자가 탭을 닫을 때.
- C: 사용자가 탭 뿐만 아니라, 브라우저 전체를 닫을 때.
-- D: 사용자가 자신의 컴퓨터를 종료시켰을때.
+- D: 사용자가 자신의 컴퓨터를 종료시켰을 때.
정답
@@ -738,7 +735,7 @@ set.has(1);
#### 정답: C
-모든 객체 키는(심볼 제외) 문자열로 직접 입력하지 않아도, 내부적으로는 문자열이에요. 이것이 `obj.hasOwnProperty('1')` 또한 true를 리턴하는 이유죠.
+모든 객체 키는(심볼 제외) 문자열로 직접 입력하지 않아도, 내부적으로는 문자열이에요. 이것이 `obj.hasOwnProperty('1')`도 true를 리턴하는 이유죠.
set에서는 작동하지 않아요. set에는 `'1'`이 없어요: `set.has('1')`는 `false`를 리턴해요. 그것은 수형인 `1`을 가지고 있어, `set.has(1)`은 `true`를 리턴해요.
@@ -764,7 +761,7 @@ console.log(obj);
#### 정답: C
-같은 이름의 키를 두 개 가지고 있다면, 첫 번째 위치에서, 마지막에 지정된 값으로 대체될 거예요.
+같은 이름의 키를 두 개 가지고 있다면, 여전히 첫 번째 위치에 있지만, 마지막에 지정된 값으로 대체될 거예요.
@@ -775,14 +772,14 @@ console.log(obj);
- A: true
- B: false
-- C: it depends
+- C: 경우에 따라 달라요
정답
#### 정답: A
-기본적인 execution context는 전역 실행 문장이에요: 당신의 코드 모든 곳에서 접근할 수 있어요.
+기본적인 실행 콘텍스트는 전역 실행 문장이에요: 당신의 코드 모든 곳에서 접근할 수 있어요.
@@ -960,7 +957,7 @@ WebAPI는 준비가 될 때마다 stack에 항목을 추가할 수 없어요.
---
-###### 32. p태그를 클릭하면 로그의 출력은 무엇일까요 ?
+###### 32. p태그를 클릭하면 로그의 출력은 무엇일까요?
```html
@@ -980,7 +977,7 @@ WebAPI는 준비가 될 때마다 stack에 항목을 추가할 수 없어요.
#### 정답: A
-`p`를 클릭하면, 2개의 로그를 볼 수 있어요: `p` 그리고 `div`. 이벤트의 전파 중에는 3 단계가 있어요: 캡처링, 타겟, 버블링. 기본적으로, 이벤트 핸들러는 버블링 단계에서 시작돼요. (`useCapture`를 `true`로 설정하지 않는 한). 가장 깊게 중첩된 요소로부터 바깥쪽으로 나가요.
+`p`를 클릭하면, 2개의 로그를 볼 수 있어요: `p` 그리고 `div`. 이벤트의 전파 중에는 3 단계가 있어요: 캡처링, 타겟, 버블링. 기본적으로, 이벤트 핸들러는 버블링 단계에서 시작돼요. (`useCapture`를 `true`로 설정하지 않는 한). 가장 깊게 중첩된 요소로부터 바깥쪽으로 나가요.
@@ -1012,7 +1009,7 @@ sayHi.bind(person, 21);
두 개 모두, `this`키워드를 참조하고자 하는 객체로 보낼 수 있어요. 그러나, `.call`은 _즉시 실행돼요_!
-`.bind.`는 함수의 _복사본_ 을 리턴하지만, 바인딩 콘텍스트죠! 이건 즉시 실행되지 않아요.
+`.bind.`는 함수의 _복사본_ 을 리턴하지만, 바인딩 콘텍스트죠! 이건 즉시 실행되지 않아요.
@@ -1041,7 +1038,7 @@ console.log(typeof sayHi());
`sayHi`함수는 즉시 호출 함수(IIFE)로서 리턴된 값을 리턴해요. 이 함수는 `0`을 리턴하고, 형은 `"number"`이에요.
-참고: 단 7개의 내장형이 있어요: `null`, `undefined`, `boolean`, `number`, `string`, `object` 그리고 `symbol`. `"function"`은 객체이기 때문에 형이 아니라 `"object"` 형이에요.
+참고: 단 7개의 내장형이 있어요: `null`, `undefined`, `boolean`, `number`, `string`, `object` 그리고 `symbol`. `"function"`은 객체이기 때문에 형이 아니라 `"object"`형이에요.
@@ -1332,7 +1329,7 @@ console.log(gen.next().value);
우선, 제너레이터 함수에서 `i`를 `10`로 초기화해요. `next()` 메소드를 사용해 제너레이터 함수를 호출해요. 처음에 제너레이터 함수를 호출하면, `i`은 `10`이에요. 첫 번째 `yield` 키워드를 만났어요: 그것은 `i`의 값을 넘겨줘요. 이제 제너레이터는 "멈추고", `10`을 출력해요.
-그 후, `next()` 메소드를 사용해 다시 한번 함수를 호출해요. `i`는 여전히 `10`이에요. 이제, 다음 `yield` 키워드를 만나 `i * 2`를 넘겨줘요. `i`는 `10`이므로, `10 * 2`, 즉 `20`을 리턴해요. 결과는 `10, 20`이에요.
+그 후, `next()` 메소드를 사용해 다시 한번 함수를 호출해요. `i`는 여전히 `10`이에요. 이제, 다음 `yield` 키워드를 만나 `i * 2`를 넘겨줘요. `i`는 `10`이므로, `10 * 2`, 즉 `20`을 리턴해요. 결과는 `10, 20`이에요.
@@ -1363,7 +1360,7 @@ Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
#### 정답: B
-복수의 프로미스를 `Promise.race` 메소드에 넘겨주면, _최초_ 의 프로미스를 해결/거부 해요. `setTimeout` 메소드에 타이머를 전달해요: 첫번째 프로미스(`firstPromise`)에는 500ms, 두번째 프로미스(`secondPromise`)에는 100ms. 이것은 `'two'`의 값을 가진 `secondPromise`가 최초로 해결한다는 것을 의미해요. 이제 `res`는 `'two'`의 값을 유지하고 출력되요.
+복수의 프로미스를 `Promise.race` 메소드에 넘겨주면, _최초_ 의 프로미스를 해결/거부 해요. `setTimeout` 메소드에 타이머를 전달해요: 첫번째 프로미스(`firstPromise`)에는 500ms, 두번째 프로미스(`secondPromise`)에는 100ms. 이것은 `'two'`의 값을 가진 `secondPromise`가 최초로 해결한다는 것을 의미해요. 이제 `res`는 `'two'`의 값을 유지하고 출력되요.
@@ -1402,7 +1399,7 @@ console.log(members);

-배열의 첫 번째 요소는 객체에 대한 다른 (복사된) 참조를 가지고 있기 때문에, `person` 변수의 값만 변경하고, 배열의 첫번째 요소는 변경할 수 없어요. `members`의 첫 번째 요소는 여전히 원본 객체에 대한 참조를 유지하고 있어요. `members` 배열을 출력할 때, 첫 번째 요소는 여전히 객체의 값을 유지하고 있어 로그가 출력돼요.
+배열의 첫 번째 요소는 객체에 대한 다른 (복사된) 참조를 가지고 있기 때문에, `person` 변수의 값만 변경하고, 배열의 첫번째 요소는 변경할 수 없어요. `members`의 첫 번째 요소는 여전히 원본 객체에 대한 참조를 유지하고 있어요. `members` 배열을 출력할 때, 첫 번째 요소는 여전히 객체의 값을 유지하고 있어 로그가 출력돼요.
@@ -1432,7 +1429,7 @@ for (const item in person) {
#### 정답: B
-`for-in` 루프를 사용하면, 객체 키를 통해서 반복할 수 있는데, 이경우에서는 `name` 그리고 `age`에요. 내부적으로, 객체 키는 문자열이에요 (심볼이 아니라면 말이죠). 모든 루프에서, `item`의 값은 반복되어 있는 현재의 키 값으로 설정해요. 우선, `item`은 `name`가 대입되어, 로그로 출력돼요. 그 후, `item`은 `age`가 대입되어, 로그로 출력돼요.
+`for-in` 루프를 사용하면, 객체 키를 통해서 반복할 수 있는데, 이경우에서는 `name` 그리고 `age`에요. 내부적으로, 객체 키는 문자열이에요 (심볼이 아니라면 말이죠). 모든 루프에서, `item`의 값은 반복되어 있는 현재의 키 값으로 설정해요. 우선, `item`은 `name`로 출력돼요. 그 후, `item`은 `age`로 출력돼요.
@@ -1459,7 +1456,7 @@ console.log(3 + 4 + "5");
처음으로 `3 + 4`가 평가되요. 결과는 숫자 `7`이에요.
-`7 + '5'`의 결과는 강제성 때문에 `"75"`가 돼요. JavaScript는 숫자 `7`을 문자열로 변환하고, (자세한 내용은)질문 15를 보세요. `+` 연산자를 사용해서 두 개의 문자열을 연결할 수 있어요. `"7" + "5"`의 결과는 `"75"`이에요.
+`7 + '5'`의 결과는 강제성 때문에 `"75"`가 돼요. JavaScript는 숫자 `7`을 문자열로 변환하고, (자세한 내용은)질문 15를 보세요. `+` 연산자를 사용해서 두 개의 문자열을 연결할 수 있어요. `"7" + "5"`의 결과는 `"75"`이에요.
@@ -1482,7 +1479,7 @@ const num = parseInt("7*6", 10);
#### 정답: C
-문자열의 첫 번째 숫자만 리턴돼요. _진법_ 에 근거하여 (파싱 하고자 하는 숫자의 기준을 명시하기 위한 두 번째 인수: 기본적인 10진수, 6진수, 8진수, 2진수 등), `parseInt`는 문자열 내의 문자가 타당한지 여부를 확인해요. 진수에 유효한 숫자가 아닌 문자를 만나면, 파싱을 멈추고, 다음 문자를 무시해요.
+문자열의 첫 번째 숫자만 리턴돼요. _진법_ 에 근거하여 (파싱 하고자 하는 숫자의 기준을 명시하기 위한 두 번째 인수: 기본적인 10진수, 6진수, 8진수, 2진수 등), `parseInt`는 문자열 내의 문자가 타당한지 여부를 확인해요. 진수에 유효한 숫자가 아닌 문자를 만나면, 파싱을 멈추고, 다음 문자를 무시해요.
`*`은 유요한 숫자가 아니에요. `"7"`만 십진수의 `7`으로 파싱 돼요. 이제 `num`은 `7`의 값을 유지해요.
@@ -1524,7 +1521,7 @@ const num = parseInt("7*6", 10);
```javascript
function getInfo(member, year) {
member.name = "Lydia";
- year = 1998;
+ year = "1998";
}
const person = { name: "Sarah" };
@@ -1545,11 +1542,11 @@ console.log(person, birthYear);
#### 정답: A
-인수들의 값이 객체가 아닌 한 _값_ 에 의해 전달되요. 그 후 _참조_ 에 의해 전달되요. `birthYear`는 객체가 아니라 문자열이기 때문에 값에 의해 전달되요. 값으로 전달하면 값의 _복사본_ 이 만들어 져요(질문 46을 보세요).
+인수들의 값이 객체가 아닌 한 _값_ 에 의해 전달되요. 그 후 _참조_ 에 의해 전달되요. `birthYear`는 객체가 아니라 문자열이기 때문에 값에 의해 전달되요. 값으로 전달하면 값의 _복사본_ 이 만들어 져요(질문 46을 보세요).
-변수 `birthYear`는 `"1997"`값에 대한 참조를 가져요. 인수 `year` 또한 `"1997"`에 대한 참조를 가지지만, `birthYear`가 가진 참조값과는 달라요. `year`에 `"1997"`을 대입하여 `year`의 값을 업데이트할 때, `year`의 값만 업데이트해요. `birthYear`는 여전히 `"1997"`이에요.
+변수 `birthYear`는 `"1997"`값에 대한 참조를 가져요. 인수 `year` 또한 `"1997"`에 대한 참조를 가지지만, `birthYear`가 가진 참조값과는 달라요. `year`에 `"1998"`을 대입하여 `year`의 값을 업데이트할 때, `year`의 값만 업데이트해요. `birthYear`는 여전히 `"1997"`이에요.
-`person`의 값은 객체예요. 인수 `member`는 _같은_ 객체의 (복사된) 참조값을 가져요. `member`객체의 속성이 갖는 참조를 변경하면, 두 개 모두 같은 객체를 참조 값을 가지고 있기 때문에, `person`의 값 또한 변경돼요. 이제 `person`'의 `name` 속성은 값 `"Lydia"`와 같아요.
+`person`의 값은 객체예요. 인수 `member`는 _같은_ 객체의 (복사된) 참조값을 가져요. `member`객체의 속성이 갖는 참조를 변경하면, 두 개 모두 같은 객체를 참조 값을 가지고 있기 때문에, `person`의 값 또한 변경돼요. 이제 `person`'의 `name` 속성은 값 `"Lydia"`에요.
@@ -1587,7 +1584,7 @@ sayHi();
`throw`문을 사용해, 커스텀 에러를 만들 수 있어요. 이 표현식을 사용해, 예외를 던질 수 있어요. 예외는
string, a
number, a
boolean or an
object이 될 수 있어요. 이 경우, 예외는 `'Hello world'` 문자열이에요.
-`catch` 문을 사용해, `try` 블록에서 예외가 던져졌을 경우에 어떻게 할지 명시할 수 있어요. 예외가 던져졌어요: 문자열 `'Hello world'`. `e`는 이제 문자열이고, 그것을 출력해요. 결과는 `'Oh an error: Hello world'`이에요.
+`catch` 문을 사용해, `try` 블록에서 예외가 던져졌을 경우에 무엇을 할지 명시할 수 있어요. 예외가 던져졌어요: 문자열 `'Hello world'`. `e`는 이제 문자열이고, 그것을 출력해요. 결과는 `'Oh an error: Hello world'`예요.
From 475d42a86b31bf704531b6c9b6b145d7f1f665f5 Mon Sep 17 00:00:00 2001
From: sweetmilkys
Date: Sun, 30 Jun 2019 03:24:50 +0900
Subject: [PATCH 123/881] Add Translate the questions 55-63 to Korean.
---
README-ko_KR.md | 299 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 299 insertions(+)
diff --git a/README-ko_KR.md b/README-ko_KR.md
index 0b926df0..7efc2bf9 100644
--- a/README-ko_KR.md
+++ b/README-ko_KR.md
@@ -1656,3 +1656,302 @@ let x = y;
+
+---
+
+###### 55. 무엇이 출력 될까요?
+
+```javascript
+class Dog {
+ constructor(name) {
+ this.name = name;
+ }
+}
+
+Dog.prototype.bark = function() {
+ console.log(`Woof I am ${this.name}`);
+};
+
+const pet = new Dog("Mara");
+
+pet.bark();
+
+delete Dog.prototype.bark;
+
+pet.bark();
+```
+
+- A: `"Woof I am Mara"`, `TypeError`
+- B: `"Woof I am Mara"`,`"Woof I am Mara"`
+- C: `"Woof I am Mara"`, `undefined`
+- D: `TypeError`, `TypeError`
+
+Answer
+
+
+#### Answer: A
+
+프로토타입에서도 `delete`키워드를 사용해, 객체로부터 속성을 삭제할 수 있어요. 프로토타입에서 속성을 삭제하면, 프로토타입 체인에서 더 이상 사용할 수 없게 돼요. 이경우, `bark`함수는 `delete Dog.prototype.bark` 후에 프로토타입에서 더 이상 사용할 수 없게 되지만, 그래도 여전히 그것에 접근하려고 해요.
+
+함수가 아닌 것을 호출하려고 할 때, `TypeError`가 던져져요. 이경우 `pet.bark`은 `undefined`이기 때문에, `TypeError: pet.bark is not a function`예요.
+
+
+
+
+---
+
+###### 56. 무엇이 출력 될까요?
+
+```javascript
+const set = new Set([1, 1, 2, 3, 4]);
+
+console.log(set);
+```
+
+- A: `[1, 1, 2, 3, 4]`
+- B: `[1, 2, 3, 4]`
+- C: `{1, 1, 2, 3, 4}`
+- D: `{1, 2, 3, 4}`
+
+Answer
+
+
+#### Answer: D
+
+`Set`는 _unique_ 값의 집합 객체예요: 값은 set 내에서 단 한 번만 발생해요.
+
+중복 값 `1`을 가진 반복 가능한 `[1, 1, 2, 3, 4]`을 전달하기 때문에, 그들 중 하나는 삭제돼요. 이것은 결과적으로 `{1, 2, 3, 4}`돼요.
+
+
+
+
+---
+
+###### 57. 무엇이 출력 될까요?
+
+```javascript
+// counter.js
+let counter = 10;
+export default counter;
+```
+
+```javascript
+// index.js
+import myCounter from "./counter";
+
+myCounter += 1;
+
+console.log(myCounter);
+```
+
+- A: `10`
+- B: `11`
+- C: `Error`
+- D: `NaN`
+
+Answer
+
+
+#### Answer: C
+
+import 된 모듈은 _read-only_ 예요 : import 된 모듈은 수정할 수 없어요. export 한 모듈만 값을 변경할 수 있어요.
+
+`myCounter`의 값을 증가 시키려고 할 때, 에러를 던져요: `myCounter`은 read-only이고 수정할 수 없어요.
+
+
+
+
+---
+
+###### 58. 무엇이 출력 될까요?
+
+```javascript
+const name = "Lydia";
+age = 21;
+
+console.log(delete name);
+console.log(delete age);
+```
+
+- A: `false`, `true`
+- B: `"Lydia"`, `21`
+- C: `true`, `true`
+- D: `undefined`, `undefined`
+
+Answer
+
+
+#### Answer: A
+
+`delete`연산자는 불린 값을 리턴해요: 성공적으로 삭제를 한 경우 `true`를, 그렇지 않다면 `false`를 리턴해요. 그러나, `var`, `const` 또는 `let` 키워드로 선언된 변수들은 `delete`연산자를 사용해서 삭제될 수 없어요.
+
+`name` 변수는 `const`키워드로 선언되었기 때문에, 삭제에 실패해요. `age`를 `21`로 설정할 때, 실제로는 `age`라는 속성을 전역 객체에 추가한 거죠. 이 방법으로 객체, 전역 객체의 속성들을 성공적으로 삭제할 수 있어요. `delete age`는 `true`을 리턴해요.
+
+
+
+
+---
+
+###### 59. 무엇이 출력 될까요?
+
+```javascript
+const numbers = [1, 2, 3, 4, 5];
+const [y] = numbers;
+
+console.log(y);
+```
+
+- A: `[[1, 2, 3, 4, 5]]`
+- B: `[1, 2, 3, 4, 5]`
+- C: `1`
+- D: `[1]`
+
+Answer
+
+
+#### Answer: C
+
+구조 분해 할당을 통해 객체의 배열 또는 속성들로부터 변수를 해체할 수 있어요. 예를 들어:
+
+```javascript
+[a, b] = [1, 2];
+```
+
+
+
+`a`는 이제 `1`이고, `b`는 이제 `2`예요. 질문에서 실제로 한 건 다음과 같아요:
+
+```javascript
+[y] = [1, 2, 3, 4, 5];
+```
+
+
+
+이것은 `y`의 값은 숫자 `1`인 배열의 첫번째 값과 같다는 것을 의미하죠. `y`를 출력하면 `1`이 리턴돼요.
+
+
+
+
+---
+
+###### 60. 무엇이 출력 될까요?
+
+```javascript
+const user = { name: "Lydia", age: 21 };
+const admin = { admin: true, ...user };
+
+console.log(admin);
+```
+
+- A: `{ admin: true, user: { name: "Lydia", age: 21 } }`
+- B: `{ admin: true, name: "Lydia", age: 21 }`
+- C: `{ admin: true, user: ["Lydia", 21] }`
+- D: `{ admin: true }`
+
+Answer
+
+
+#### Answer: B
+
+스프레드 연산자 `...`를 사용해 객체를 결합할 수 있어요. 이것은 하나의 객체의 키/값의 쌍들을 복사본들을 만들어, 다른 객체에 추가해요. 이 경우, `user` 객체의 복사 본들을 만들어, `admin` 객체에 추가해요. `admin` 객체는 이제 복사된 키/값의 쌍들이 들어있고, 결과는 `{ admin: true, name: "Lydia", age: 21 }`예요.
+
+
+
+
+---
+
+###### 61. 무엇이 출력 될까요?
+
+```javascript
+const person = { name: "Lydia" };
+
+Object.defineProperty(person, "age", { value: 21 });
+
+console.log(person);
+console.log(Object.keys(person));
+```
+
+- A: `{ name: "Lydia", age: 21 }`, `["name", "age"]`
+- B: `{ name: "Lydia", age: 21 }`, `["name"]`
+- C: `{ name: "Lydia"}`, `["name", "age"]`
+- D: `{ name: "Lydia"}`, `["age"]`
+
+Answer
+
+
+#### Answer: B
+
+`defineProperty`메소드로, 객체에 새로운 속성들을 추가하거나, 기존 것을 수정할 수 있어요. `defineProperty` 메소드를 사용해 객체의 속성을 추가할 때, 기본적으로 객체의 속성들은 _비 열거자_ 예요. `Object.keys`메소드는 모든 _열거자_ 객체의 속성 이름들을 리턴하는데, 이 경우는 `"name"` 뿐이에요.
+
+`defineProperty`를 사용해 추가된 속성들은 기본적으로 변경할 수 없어요. `writable`, `configurable` 그리고 `enumerable` 속성들을 사용해 덮어쓰기 할 수 있어요. `defineProperty`메소드의 방법은 객체에 추가할 속성들을 훨씬 더 정교 하게 제어하도록 해줘요.
+
+
+
+
+---
+
+###### 62. 무엇이 출력 될까요?
+
+```javascript
+const settings = {
+ username: "lydiahallie",
+ level: 19,
+ health: 90
+};
+
+const data = JSON.stringify(settings, ["level", "health"]);
+console.log(data);
+```
+
+- A: `"{"level":19, "health":90}"`
+- B: `"{"username": "lydiahallie"}"`
+- C: `"["level", "health"]"`
+- D: `"{"username": "lydiahallie", "level":19, "health":90}"`
+
+Answer
+
+
+#### Answer: A
+
+`JSON.stringify` 두번째 인수는 _replacer_ 예요. replacer는 함수 또는 배열 둘 중 하나가 될 수 있고, stringify 할 대상과 방법을 제어 할 수 있게 해줘요.
+
+replacer가 _배열_ 이라면, 배열에 이름이 포함된 속성만 JSON 문자열에 추가될 거에요. 이 경우, 이름을 가진 `"level"` 그리고 `"health"`속성들만 포함되고, `"username"`은 제외되요. `data` 은 이제 `"{"level":19, "health":90}"`에요.
+
+replacer가 _함수_ 라면, stringifying 할 객체의 모든 속성에 호출돼요. 이 함수로부터 리턴된 값은 JSON 문자열에 추가될 때 속성의 값이 될 거에요. 만약 값이 `undefined`라면, 이 속성은 JSON 문자열로부터 제외돼요.
+
+
+
+
+---
+
+###### 63. 무엇이 출력 될까요?
+
+```javascript
+let num = 10;
+
+const increaseNumber = () => num++;
+const increasePassedNumber = number => number++;
+
+const num1 = increaseNumber();
+const num2 = increasePassedNumber(num1);
+
+console.log(num1);
+console.log(num2);
+```
+
+- A: `10`, `10`
+- B: `10`, `11`
+- C: `11`, `11`
+- D: `11`, `12`
+
+Answer
+
+
+#### Answer: A
+
+단항 연산자 `++`는 _우선_ 피연산자의 값을 _리턴하고_, _그 후_ 피연산자의 값을 _증가해요_. `increaseNumber` 함수이 처음으로 리턴 한 `num`의 값은 `10` 이기 때문에, `num1`의 값은 `10`이고, 그 후엔 `num`의 값만 증가해요.
+
+`num1`을 `increasePassedNumber`로 전달했기 때문에, `num2`는 `10`이에요. `number`는 `10`이에요(`num1`의 값은, 다시 한번, 단항 연산자가 `++`는 _우선_ 피연산자의 값을 _리턴하고_, _그 후_ 피연산자의 값을 _증가해요_. `number`의 값은 `10`이에요 즉, `num2`는 `10`이죠.
+
+
+
From 88d6a3f7017beb1abfb1527203742aa487b99cdf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrian=20Go=C5=82awski?=
Date: Sat, 29 Jun 2019 20:27:04 +0200
Subject: [PATCH 124/881] Fixing typo in the main document
numebers => numbers
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index d4fffadb..3be1c1f8 100644
--- a/README.md
+++ b/README.md
@@ -1796,7 +1796,7 @@ The `name` variable was declared with a `const` keyword, so its deletion is not
```javascript
const numbers = [1, 2, 3, 4, 5];
-const [y] = numberes;
+const [y] = numbers;
console.log(y);
```
From a624dbf9e4701e9160009b0b05f2ebba617afe80 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Sun, 30 Jun 2019 12:14:41 +0200
Subject: [PATCH 125/881] Questions from 55 to 63 translated into arabic
---
README_AR.md | 302 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 302 insertions(+)
diff --git a/README_AR.md b/README_AR.md
index 05d51b95..806ef11f 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -1732,3 +1732,305 @@ let x = y;
+
+---
+
+55. ماهو الناتج؟
+
+```javascript
+class Dog {
+ constructor(name) {
+ this.name = name;
+ }
+}
+
+Dog.prototype.bark = function() {
+ console.log(`Woof I am ${this.name}`);
+};
+
+const pet = new Dog("Mara");
+
+pet.bark();
+
+delete Dog.prototype.bark;
+
+pet.bark();
+```
+
+- A: `"Woof I am Mara"`, `TypeError`
+- B: `"Woof I am Mara"`,`"Woof I am Mara"`
+- C: `"Woof I am Mara"`, `undefined`
+- D: `TypeError`, `TypeError`
+
+الإجابة
+
+
+الجواب هو الخيار الأول: A
+
+بإمكاننا مسح خصائص object معين عن طريق استخدام الكلمة المفتاحية `delete`, أيضا يمكن فعل هذا في ال prototype. بمسح خاصية معينة من الprototype, فهي سيتم مسحها وبالتالي لن تكون موجودة في سلسلة الprototype. في هذه الحالة فإن الدالة `bark` لن تكون موجودة بعد الآن في الprototype بعد `delete Dog.prototype.bark`, ولكن بالرغم من هذا فنحن نحاول الوصول إليها.
+
+عندما نحاول أن ننادي شيئا ما في دالة و هو ليس موجود في هذه الدالة, فإننا سنتحصل على الخطأ `TypeError`, و في هذه الحالة `TypeError: pet.bark is not a function` بما أن `pet.bark` هي `undefined`.
+
+
+
+
+---
+
+56. ماهو الناتج؟
+
+```javascript
+const set = new Set([1, 1, 2, 3, 4]);
+
+console.log(set);
+```
+
+- A: `[1, 1, 2, 3, 4]`
+- B: `[1, 2, 3, 4]`
+- C: `{1, 1, 2, 3, 4}`
+- D: `{1, 2, 3, 4}`
+
+الإجابة
+
+
+الجواب هو الخيار الرابع: D
+
+ال object `Set` هو مجموعة من القيم الفريدة, أي القيمة بإمكانها أن تتواجد مرة واحدة فقط في المجموعة.
+
+نقوم بتمرير التكراري أي نعني الiterable `[1, 1, 2, 3, 4]` بوجود قيمة مكررة ألا وهي `1` . بما أننا لا يمكن أن نضع قيمة واحدة مرتين في مجموعة, فإن واحدة من القيم المكررة سيتم إزالتها, و سيكون الناتج: `{1, 2, 3, 4}`.
+
+
+
+
+---
+
+57. ماهو الناتج؟
+
+```javascript
+// counter.js
+let counter = 10;
+export default counter;
+```
+
+```javascript
+// index.js
+import myCounter from "./counter";
+
+myCounter += 1;
+
+console.log(myCounter);
+```
+
+- A: `10`
+- B: `11`
+- C: `Error`
+- D: `NaN`
+
+الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+هنا يوجد لدينا module مستورد وهو قابل للقراءة فقط, ليس بإمكانك تعديل او تحديث الmodule المستورد, أي imported module. فقط الmodule الذي قام بتصديره هو القادر على تغيير قيمته.
+
+عندما نحاول أن نزيد قيمة المتغير `myCounter`, سنتحصل على الخطأ `myCounter` هو قابل للقراءة فقط و ليس من الممكن تعديله.
+
+
+
+
+---
+
+58. ماهو الناتج؟
+
+```javascript
+const name = "Lydia";
+age = 21;
+
+console.log(delete name);
+console.log(delete age);
+```
+
+- A: `false`, `true`
+- B: `"Lydia"`, `21`
+- C: `true`, `true`
+- D: `undefined`, `undefined`
+
+الإجابة
+
+
+الجواب هو الخيار الأول: A
+
+العامل `delete` تقوم بإرجاع قيمة boolen و هي `true` عندما تتم عملية المسح بنجاح, خلاف ذلك ستقوم بإرجاع `false`, ولكن المتغيرات المعرفة بالكلمات المفتاحية `var`, `const` أو `let` ليس بالإمكان مسحها بإستخدام العامل `delete`.
+
+المتغير `name` تم تعريفه باستخدام الكلمة المفتاحية `const`, لهذا فإن عملية مسحه لم تتم بنجاح, وتم إرجاع القيمة `false`, عندما نقوم بضبط المتغير `age` ليساوي القيمة `21` فإننا فعليا نقوم بإضافة خاصية تسمى `age` للglopal object. بإمكانك أن تمسح خصائص من الobjects بنجاح بإستخدام هذه الطريقة , أيضا الglopal objects, لذا فإن `delete age` تقوم بإرجاع `true`.
+
+
+
+---
+
+59. ماهو الناتج؟
+
+```javascript
+const numbers = [1, 2, 3, 4, 5];
+const [y] = numbers;
+
+console.log(y);
+```
+
+- A: `[[1, 2, 3, 4, 5]]`
+- B: `[1, 2, 3, 4, 5]`
+- C: `1`
+- D: `[1]`
+
+
الإجابة
+
+
+الجواب هو الخيار الثالث: C
+
+بإمكاننا إستخراج أو استخلاص القيم من arrays أو من objects عن طريق إستخدام الdestructing, على سبيل المثال:
+
+
+```javascript
+[a, b] = [1, 2];
+```
+
+
+

+
+قيمة `a` الآن تساوي `1`, و قيمة `b` الآن تساوي `2`. ماقمنا بفعله حقاً في هذا السؤال هو:
+
+
+```javascript
+[y] = [1, 2, 3, 4, 5];
+```
+
+
+

+
+هذا يعني أن قيمة `y` هي مساوية للقيمة الأولى في الarray, والتي هي عبارة عن نوع رقم يساوي `1`, عندما نقوم بطباعة `y` عن طريق الlog, فإن القيمة `1` هي التي يتم إرجاعها.
+
+
+
+
+---
+
+60. ماهو الناتج؟
+
+```javascript
+const user = { name: "Lydia", age: 21 };
+const admin = { admin: true, ...user };
+
+console.log(admin);
+```
+
+- A: `{ admin: true, user: { name: "Lydia", age: 21 } }`
+- B: `{ admin: true, name: "Lydia", age: 21 }`
+- C: `{ admin: true, user: ["Lydia", 21] }`
+- D: `{ admin: true }`
+
+الإجابة
+
+
+الجواب هو الخيار الثاني: B
+
+من الممكن دمج الobjects بإستخدام العامل spread `...`. هي تمكنك من إنشاء نسخ من أزواج ال key/value أي أزواج المفاتيح و القيم التي تنتمي الى object معين, و إضافتهم الى object آخر. في هذه الحالة, نحن نقوم بعمل نسخ من الobject `user`, و من ثم إضافتهم الى ال obejct `admin`. ال object `admin` الآن يتضمن نسخ عبارة عن أزواج مفاتيح و قيم, و هذا ما سبب في إعطاء النتيجة `{ admin: true, name: "Lydia", age: 21 }`.
+
+
+
+
+---
+
+61. ماهو الناتج؟
+
+```javascript
+const person = { name: "Lydia" };
+
+Object.defineProperty(person, "age", { value: 21 });
+
+console.log(person);
+console.log(Object.keys(person));
+```
+
+- A: `{ name: "Lydia", age: 21 }`, `["name", "age"]`
+- B: `{ name: "Lydia", age: 21 }`, `["name"]`
+- C: `{ name: "Lydia"}`, `["name", "age"]`
+- D: `{ name: "Lydia"}`, `["age"]`
+
+الإجابة
+
+
+الجواب هو الخيار الثاني: B
+
+مع إستخدام `defineProperty` method, بإمكاننا إضافة خصائص جديدة لobject معين,أو تعديل خصائصه الحالية,. عندما نقوم بإضافة خاصية لobject بإستخدام `defineProperty` method, ف هي بطبيعة الحال ليست enumerable. ال `Object.keys` method تقوم بإرجاع جميع أسامي الخصائص من object معين و التي هي جميعها enumerable, في هذه الحالة `"name"` فقط.
+
+الخصائص التي تم إضافتها بإستخدام `defineProperty` method هي بطبيعة الحال غير قابلة للتغيير أو التعديل. بإمكانك عمل override بإستخدام الخصائص `writable`, `configurable` و `enumerable`. بهذه الطريقة, ال `defineProperty` method ستعطيك تحكم أكثر بكثير على الخصائص التي قمت بإضافتها الى object معين.
+
+
+
+
+---
+
+62. ماهو الناتج؟
+
+```javascript
+const settings = {
+ username: "lydiahallie",
+ level: 19,
+ health: 90
+};
+
+const data = JSON.stringify(settings, ["level", "health"]);
+console.log(data);
+```
+
+- A: `"{"level":19, "health":90}"`
+- B: `"{"username": "lydiahallie"}"`
+- C: `"["level", "health"]"`
+- D: `"{"username": "lydiahallie", "level":19, "health":90}"`
+
+الإجابة
+
+
+الجواب هو الخيار الأول : A
+
+ال argument الثاني من `JSON.stringify` هو replacer أي حالٍ محل شيء آخر, الreplacer إما أن يكون دالة أو يكون array, و سيمكنك من التحكم في كيفية و ماهية امكانية عمل stringified للقيم, أي تحويلها الى string.
+
+إذا كان الreplacer هو عبارة عن array, فإن الخصائص التي أساميها مضمنة في الarray هي فقط التي يمكن إضافتها الى ال JSON string. في هذه الحالة, الخصائص التي تحمل الأسامي `"level"` و `"health"` فقط هي المضمنة, `"username"` غير مضمنة. `data` الآن تساوي `"{"level":19, "health":90}"`.
+
+إذا كان الreplacer عبارة عن دالة, فإن هذه الدالة يتم مناداتها عند أي خاصية في الobject أنت تقوم بعمل stringifying لها.القيمة المرجعة من هذه الدالة ستكون قيمة الخاصية عندما تم إضافتها ل JSON string. إذا كانت القيمة `undefined`, فإن هذه الخاصية سيتم إستبعادها من الJSON string.
+
+
+
+
+---
+
+63. ماهو الناتج؟
+
+```javascript
+let num = 10;
+
+const increaseNumber = () => num++;
+const increasePassedNumber = number => number++;
+
+const num1 = increaseNumber();
+const num2 = increasePassedNumber(num1);
+
+console.log(num1);
+console.log(num2);
+```
+
+- A: `10`, `10`
+- B: `10`, `11`
+- C: `11`, `11`
+- D: `11`, `12`
+
+الإجابة
+
+
+الجواب هو الخيار الأول : A
+
+العامل الأحادي `++` يقوم أولا بإرجاع قيمة المعامل, ثم يقوم بزيادة قيمة هذا المعامل. قيمة `num1` تساوي `10`, و بما أن دالة `increaseNumber` أولا تقوم بإرجاع قيمة `num` و التي هي تساوي `10`, و تقوم بزيادة قيمة `num` لاحقاً فقط.
+
+`num2` تساوي`10`, وبما أننا نقوم بتمرير `num1` ل `increasePassedNumber`. فإن `number` تساوي `10` والتي هي قيمة`num1`. مجدداً, العامل الأحادي `++`, أولاً يقوم بإرجاع قيمة المعامل, و من ثم زيادة قيمة المعامل. قيمة `number` تساوي`10`, إذاً `num2` تساوي `10`.
+
+
+
From c3e178e6309e4fbb2b4b7c84eaf45e1809412295 Mon Sep 17 00:00:00 2001
From: Jacob Herper
Date: Sun, 30 Jun 2019 11:19:14 +0100
Subject: [PATCH 126/881] Added questions 55-63 and added new languages
---
README-de_DE.md | 303 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 303 insertions(+)
diff --git a/README-de_DE.md b/README-de_DE.md
index 51456884..4ff1bf12 100644
--- a/README-de_DE.md
+++ b/README-de_DE.md
@@ -6,9 +6,12 @@ Von einfach bis fortgeschritten: teste wie gut du JavaScript kennst, frische dei
Die Antworten sind unterhalb der Fragen versteckt. Du kannst einfach darauf klicken um die Antworten anzuzeigen. Viel Glück :heart:
+### Andere verfügbare Sprachen
[English](./README.md)
[Bosanski Jezik](./README-bs_BS.md)
[日本語](./README-ja_JA.md)
+[한국어](./README-ko_KR.md)
+[Português Brasil](./README_pt_BR.md)
[Русский](./README_ru-RU.md)
[Українська мова](./README-ua_UA.md)
[Tiếng Việt](./README-vi.md)
@@ -1653,3 +1656,303 @@ Da wir die Variable `y` aber global erstellt haben ist ihr Wert `10` auch hier v
+
+
+---
+
+###### 55. Was ist der Output?
+
+```javascript
+class Dog {
+ constructor(name) {
+ this.name = name;
+ }
+}
+
+Dog.prototype.bark = function() {
+ console.log(`Woof I am ${this.name}`);
+};
+
+const pet = new Dog("Mara");
+
+pet.bark();
+
+delete Dog.prototype.bark;
+
+pet.bark();
+```
+
+- A: `"Woof I am Mara"`, `TypeError`
+- B: `"Woof I am Mara"`,`"Woof I am Mara"`
+- C: `"Woof I am Mara"`, `undefined`
+- D: `TypeError`, `TypeError`
+
+Antwort
+
+
+#### Antwort: A
+
+Properties von Objekten können mit dem `delete` Keyword entfernt werden, selbst am Prototype. Beim entfernen von Properties am Prototype ist zu beachten, dass diese dann aus der Prototypen-Kette verschwinden. In unserem Fall existiert die `bark` Funktion nicht mehr am Prototype nachdem `delete Dog.prototype.bark` ausgeführt wurde.
+
+Wenn wir versuchen etwas auszuführen, was keine Funktion ist, wird ein `TypeError` ausgeworfen. In diesem Fall `TypeError: pet.bark is not a function`, da `pet.bark` `undefined` ist.
+
+
+
+
+---
+
+###### 56. Was ist der Output?
+
+```javascript
+const set = new Set([1, 1, 2, 3, 4]);
+
+console.log(set);
+```
+
+- A: `[1, 1, 2, 3, 4]`
+- B: `[1, 2, 3, 4]`
+- C: `{1, 1, 2, 3, 4}`
+- D: `{1, 2, 3, 4}`
+
+Antwort
+
+
+#### Antwort: D
+
+Das `Set` Objekt ist eine Sammlung von _eindeutigen_ Werten: jeder Wert kann nur ein Mal in einem Set vorkommen.
+
+Wir übergeben `[1, 1, 2, 3, 4]` mit einer doppelten `1`. Da wir keine doppelten Werte in einem Set haben können wird eine `1` entfernt. Das Ergebnis ist `{1, 2, 3, 4}`.
+
+
+
+
+---
+
+###### 57. Was ist der Output?
+
+```javascript
+// counter.js
+let counter = 10;
+export default counter;
+```
+
+```javascript
+// index.js
+import myCounter from "./counter";
+
+myCounter += 1;
+
+console.log(myCounter);
+```
+
+- A: `10`
+- B: `11`
+- C: `Error`
+- D: `NaN`
+
+Antwort
+
+
+#### Antwort: C
+
+Ein importiertes Modul ist _read-only_, was bedeutet, dass importierte Module nicht geändert werden können. Nur das Modul, welches diese exportiert kann deren Wert ändern.
+
+Wenn wir also den Wert von `myCounter` erhöhen bekommen wir den Fehler `myCounter is read-only and cannot be modified`.
+
+
+
+
+---
+
+###### 58. Was ist der Output?
+
+```javascript
+const name = "Lydia";
+age = 21;
+
+console.log(delete name);
+console.log(delete age);
+```
+
+- A: `false`, `true`
+- B: `"Lydia"`, `21`
+- C: `true`, `true`
+- D: `undefined`, `undefined`
+
+Antwort
+
+
+#### Antwort: A
+
+Der `delete` Operator gibt einen Boolean Wert zurück: `true` bei erfolgreichem entfernen, oder andernfalls `false`. Variablen, die mit `var`, `let` oder `const` deklariert werden, können andererseits nicht mit `delete` entfernt werden.
+
+Der Wert von `name` wurde mit `const` deklariert, weshalb `delete` nicht möglich ist und `false` zurückgegeben wird. Als wir `age` den Wert `21` zugewiesen haben, haben wir eine Property `age` zum globalen Objekt hinzugefügt. Diese Properties kann man mit `delete` entfernen, sodass `delete age` `true` zurückgibt.
+
+
+
+
+---
+
+###### 59. Was ist der Output?
+
+```javascript
+const numbers = [1, 2, 3, 4, 5];
+const [y] = numbers;
+
+console.log(y);
+```
+
+- A: `[[1, 2, 3, 4, 5]]`
+- B: `[1, 2, 3, 4, 5]`
+- C: `1`
+- D: `[1]`
+
+Antwort
+
+
+#### Antwort: C
+
+Wir können durch Destructuring Werte aus Arrays oder Properties aus Objekten entpacken. Zum Beispiel:
+
+```javascript
+[a, b] = [1, 2];
+```
+
+
+
+Der Wert von `a` ist jetzt `1` und der Wert von `b` ist jetzt `2`. Was wir in der Frage eigentlich getan haben ist:
+
+```javascript
+[y] = [1, 2, 3, 4, 5];
+```
+
+
+
+Das bedeutet, dass der Wert von `y` gleich des ersten Wertes im Array ist, sprich der Zahl `1` entspricht. Wenn wir `y` loggen bekommen wir `1` ausgegeben.
+
+
+
+
+---
+
+###### 60. Was ist der Output?
+
+```javascript
+const user = { name: "Lydia", age: 21 };
+const admin = { admin: true, ...user };
+
+console.log(admin);
+```
+
+- A: `{ admin: true, user: { name: "Lydia", age: 21 } }`
+- B: `{ admin: true, name: "Lydia", age: 21 }`
+- C: `{ admin: true, user: ["Lydia", 21] }`
+- D: `{ admin: true }`
+
+Antwort
+
+
+#### Antwort: B
+
+Es ist möglich Objekte mit dem Spread Operator `...` zu verbinden. Dieser erstellt Kopien der Key/Value Paare eines Objektes und fügt diese dem anderen Objekt hinzu. In diesem Fall wird eine Kopie des `user` Objekts erstellt und dem `admin` Objekt zugewiesen. Das `admin` Objekt beinhaltet nun die kopierten Key/Value Paare, sodass das Ergebnis `{ admin: true, name: "Lydia", age: 21 }` ist.
+
+
+
+
+---
+
+###### 61. Was ist der Output?
+
+```javascript
+const person = { name: "Lydia" };
+
+Object.defineProperty(person, "age", { value: 21 });
+
+console.log(person);
+console.log(Object.keys(person));
+```
+
+- A: `{ name: "Lydia", age: 21 }`, `["name", "age"]`
+- B: `{ name: "Lydia", age: 21 }`, `["name"]`
+- C: `{ name: "Lydia"}`, `["name", "age"]`
+- D: `{ name: "Lydia"}`, `["age"]`
+
+Antwort
+
+
+#### Antwort: B
+
+Mit der `defineProperty` Methode können wir neue Properties zu einem Objekt hinzufügen oder bestehende modifizieren. Wenn wir mit der `defineProperty` Methode Properties einem Objekt hinzufügen, sind diese standardmäßig _nicht zählbar_. Die `Object.keys` Methode gibt alle _zählbaren_ Property Namen eines Objektes zurück, in diesem Fall nur `"name"`.
+
+Properties, die mit `defineProperty` erstellt wurden sind standardmäßig unveränderbar. Man kann dieses Verhalten mit den `writable`, `configurable` und `enumerable` Properties verändern. Auf diese Art gibt die `defineProperty` Methode mehr Kontrolle über die Properties, die einem Objekt hinzugefügt werden.
+
+
+
+
+---
+
+###### 62. Was ist der Output?
+
+```javascript
+const settings = {
+ username: "lydiahallie",
+ level: 19,
+ health: 90
+};
+
+const data = JSON.stringify(settings, ["level", "health"]);
+console.log(data);
+```
+
+- A: `"{"level":19, "health":90}"`
+- B: `"{"username": "lydiahallie"}"`
+- C: `"["level", "health"]"`
+- D: `"{"username": "lydiahallie", "level":19, "health":90}"`
+
+Antwort
+
+
+#### Antwort: A
+
+Das zweite Argument von `JSON.stringify` ist ein _Replacer_. Der Replacer kann entweder eine Funktion oder ein Array sein und gibt uns Kontrolle darüber, wie die Werte in Strings umgewandelt werden sollen.
+
+Wenn der Replacer ein _Array_ ist, werden nur die Properties dem JSON String hinzugefügt, die in dem Array aufgeführt sind. In diesem Fall sind das nur `"level"` und `"health"`. `"username"` ist ausgeschlossen. `data` ist jetzt gleich `"{"level":19, "health":90}"`.
+
+Wenn der Replacer eine _Funktion_ ist, so wird diese Funktion für jede Property im Objekt aufgerufen, die in Strings umgewandelt wird. Der Wert, den die Funktion zurückgibt, ist der Wert der Property, die dem JSON String hinzugefügt wird. Ist der Wert `undefined`, so wird die Property ausgeschlossen.
+
+
+
+
+---
+
+###### 63. Was ist der Output?
+
+```javascript
+let num = 10;
+
+const increaseNumber = () => num++;
+const increasePassedNumber = number => number++;
+
+const num1 = increaseNumber();
+const num2 = increasePassedNumber(num1);
+
+console.log(num1);
+console.log(num2);
+```
+
+- A: `10`, `10`
+- B: `10`, `11`
+- C: `11`, `11`
+- D: `11`, `12`
+
+Antwort
+
+
+#### Antwort: A
+
+Der unäre Operator `++` _gibt zuerst_ den Wert des Operanden aus und _erhöht danach_ den Wert des Operanden. Der Wert `num1` ist `10`, da `increaseNumber` zuerst den Wert von `num1` (`10`) ausgibt und ihn danach erhöht.
+
+`num2` ist gleich `10`, da wir `num1` `increasePassedNumber` zugewiesen haben. `number` ist gleich `10` (der Wert von `num1`). Der unäre Operator `++` gibt erneut _zuerst_ den Wert des Operanden aus und _erhöht danach_ den Wert. Der Wert von `number` ist `10`, sodass `num2` ebenfalls `10` ist.
+
+
+
From cf0968aad3ec9ceb67fd1eebec82c17f1d61f8ab Mon Sep 17 00:00:00 2001
From: Lydia
Date: Sun, 30 Jun 2019 13:06:48 +0200
Subject: [PATCH 127/881] Rephrase question 19
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index d684f98f..e64496b7 100644
--- a/README.md
+++ b/README.md
@@ -602,7 +602,7 @@ getAge(21);
#### Answer: C
-The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
+The rest parameter (`...args`.) lets us "collect" all remaining arguments into an array. An array is an object, so `typeof args` returns `"object"`
From a4294c2835c76f44f7ba51e4c7dedb78a765a092 Mon Sep 17 00:00:00 2001
From: Gabriel Sroka
Date: Sun, 30 Jun 2019 07:31:44 -0700
Subject: [PATCH 128/881] Update README.md
fixed typo and added link from "June 29th" to question 55
---
README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 3be1c1f8..3af8e328 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
I post daily multiple choice JavaScript questions on my [Instagram](https://www.instagram.com/theavocoder), which I'll also post here!
-From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle: :rocket: I update this repo weekly with new questions. Last update: June 29th
+From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle: :rocket: I update this repo weekly with new questions. Last update: June 29th
The answers are in the collapsed sections below the questions, simply click on them to expand it. Good luck :heart:
@@ -1659,7 +1659,7 @@ However, we created a global variable `y` when setting `y` equal to `10`. This v
---
-###### 55. What's the output?
+###### 55. What's the output?
```javascript
class Dog {
@@ -1783,7 +1783,7 @@ console.log(delete age);
#### Answer: A
-The `delete` operator returns a boolena value: `true` on a successful deletion, else it'll return `false`. However, variables declared with the `var`, `const` or `let` keyword cannot be deleted using the `delete` operator.
+The `delete` operator returns a boolean value: `true` on a successful deletion, else it'll return `false`. However, variables declared with the `var`, `const` or `let` keyword cannot be deleted using the `delete` operator.
The `name` variable was declared with a `const` keyword, so its deletion is not successful: `false` is returned. When we set `age` equal to `21`, we actually added a property called `age` to the global object. You can successfully delete properties from objects this way, also the global object, so `delete age` returns `true`.
From 59771501f77cd7759e8e8c7fdd06d148fd8f74ec Mon Sep 17 00:00:00 2001
From: Gabriel Sroka
Date: Sun, 30 Jun 2019 07:34:13 -0700
Subject: [PATCH 129/881] Update README.md
1 more typo
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 3af8e328..9b680d87 100644
--- a/README.md
+++ b/README.md
@@ -1811,7 +1811,7 @@ console.log(y);
#### Answer: C
-We can unpack values from arrays or properties from objects through destructing. For example:
+We can unpack values from arrays or properties from objects through destructuring. For example:
```javascript
[a, b] = [1, 2];
From e933fcbf05359a356a640f93ddc0ce627ea60fc2 Mon Sep 17 00:00:00 2001
From: Sara Ahmed
Date: Sun, 30 Jun 2019 18:10:07 +0200
Subject: [PATCH 130/881] Updated the introduction
---
README_AR.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README_AR.md b/README_AR.md
index 806ef11f..09078392 100644
--- a/README_AR.md
+++ b/README_AR.md
@@ -18,12 +18,13 @@
* [中文版本](./README-zh_CN.md)
* [Versión en español](./README-ES.md)
* [日本語](./README-ja_JA.md)
+* [한국어](./README-ko_KR.md)
* [Русский](./README_ru-RU.md)
* [Western Balkan](./README-bs_BS.md)
* [Deutsch](./README-de_DE.md)
* [Tiếng Việt](./README-vi.md)
* [Українська мова](./README-ua_UA.md)
-* [Português Brasil](./README_pt_BR.md)
+* [Português Brasil](./README_pt_BR.md)
____________
From 5afff59df695cb91a8c385135404cccfa27350da Mon Sep 17 00:00:00 2001
From: Yoon Seonggwon
Date: Mon, 1 Jul 2019 15:10:11 +0900
Subject: [PATCH 131/881] Fix typos
Signed-off-by: Yoon Seonggwon
---
README-ko_KR.md | 188 ++++++++++++++++++++++++------------------------
1 file changed, 94 insertions(+), 94 deletions(-)
diff --git a/README-ko_KR.md b/README-ko_KR.md
index 7efc2bf9..6214a0d7 100644
--- a/README-ko_KR.md
+++ b/README-ko_KR.md
@@ -42,9 +42,9 @@ sayHi();
#### 정답: D
-함수 내에서, 우선 `var`키워드를 사용해 `name`변수를 선언해요. 이것은 변수가 정의되어 있는 행에 실제로 도달할 때까지, `undefined`의 기본값으로 호이스팅 되(생성단계에 메모리 공간이 설정)는 것을 의미해요. `name` 변수를 출력하려는 줄에서 아직 변수를 정의하고 있지 않기 때문에, `undefined`값을 유지하고 있어요.
+함수 내에서, 우선 `var` 키워드를 사용해 `name` 변수를 선언해요. 이것은 변수가 정의된 행에 실제로 도달할 때까지, `undefined`의 기본값으로 호이스팅 되(생성단계에 메모리 공간이 설정)는 것을 의미해요. `name` 변수를 출력하려는 줄에서 아직 변수를 정의하고 있지 않기 때문에, `undefined` 값을 유지하고 있어요.
-`let`키워드(그리고 `const`)를 가지는 변수들은, `var`와는 달리, 호이스팅되지만 초기화되지 않아요. 그것들을 선언(초기화)하는 줄 전에는 접근할 수 없어요. 이것은 "일시적 사각지대"라고 불려요. 선언되기 전 변수에 접근하려고 하면, JavaScript는 `ReferenceError`를 던져요.
+`let` 키워드(그리고 `const`)를 가지는 변수들은, `var`와는 달리, 호이스팅 되지만 초기화 되지 않아요. 그것들을 선언(초기화)하는 줄 전에는 접근할 수 없어요. 이것은 "일시적 사각지대"라고 불려요. 선언되기 전 변수에 접근하려고 하면, JavaScript는 `ReferenceError`를 던져요.
@@ -72,9 +72,9 @@ for (let i = 0; i < 3; i++) {
#### 정답: C
-JavaScript의 이벤트 큐 때문에, `setTimeout`의 콜백 함수는 루프가 실행된 _후에_ 호출돼요. 첫 번째의 루프 변수 `i`는 `var`키워드를 사용해 선언되어 있기 때문에, 이 값은 전역 변수가 돼요. 루프 동안, 단항 연산자 `++`를 사용하여, 매번 `i`의 값을 `1`씩 증가했어요. `setTimeout`콜백 함수가 호출되기까지, 첫 번째 예에서 `i`는 `3`이에요.
+JavaScript의 이벤트 큐 때문에, `setTimeout`의 콜백 함수는 루프가 실행된 _후에_ 호출돼요. 첫 번째의 루프 변수 `i`는 `var` 키워드를 사용해 선언되어 있기 때문에, 이 값은 전역 변수가 돼요. 루프 동안, 단항 연산자 `++`를 사용하여, 매번 `i`의 값을 `1`씩 증가했어요. `setTimeout`콜백 함수가 호출되기까지, 첫 번째 예에서 `i`는 `3`이에요.
-두 번째 루프에서, 변수 `i`는 `let`키워드를 사용해 선언되었어요: `let`(그리고 `const`)키워드로 선언된 변수는 블록 범위예요(블록은 `{ }` 사이의 모든 것). 각각의 반복 동안, `i`는 새로운 값을 가지고, 각각의 값은 루프 안쪽 범위에 있어요.
+두 번째 루프에서, 변수 `i`는 `let` 키워드를 사용해 선언되었어요: `let`(그리고 `const`) 키워드로 선언된 변수는 블록 범위예요(블록은 `{ }` 사이의 모든 것). 각각의 반복 동안, `i`는 새로운 값을 가지고, 각각의 값은 루프 안쪽 범위에 있어요.
@@ -106,9 +106,9 @@ console.log(shape.perimeter());
#### 정답: B
-`diameter`의 값은 정규 함수인 반면, `perimeter`의 값은 화살표 함수라는 점을 유의하세요.
+`diameter`의 값은 정규 함수지만, `perimeter`의 값은 화살표 함수라는 점을 유의하세요.
-화살표 함수에서, `this`키워드는 통상적인 함수와는 다르게 현재 주위의 범위를 참조해요! 이것은 `perimeter`를 부르면, shape 객체가 아닌 그 주위의 범위(예를 들면 window)를 참조하는 것을 의미해요.
+화살표 함수에서, `this` 키워드는 통상적인 함수와는 다르게 현재 주위의 범위를 참조해요! 이것은 `perimeter`를 부르면, shape 객체가 아닌 그 주위의 범위(예를 들면 window)를 참조하는 것을 의미해요.
그 객체에는 `radius`라는 값은 없기 때문에 `undefined`를 리턴해요.
@@ -133,9 +133,9 @@ console.log(shape.perimeter());
#### 정답: A
-단항 더하기는 피연산자를 숫자로 변환하려 시도 해요. `true`는 `1`이고, `false`은 `0`이에요.
+단항 더하기는 피연산자를 숫자로 변환하려 시도해요. `true`는 `1`이고, `false`는 `0`이에요.
-문자열 `'Lydia'`는 참 같은 값이에요. 실제로는, "이 참 같은 값이 거짓 같은 값인가?"를 물어보고 있어요. 이것은 `false`을 리턴해요.
+문자열 `'Lydia'`는 참 같은 값이에요. 실제로는, "이 참 같은 값이 거짓 같은 값인가?"를 물어보고 있어요. 이것은 `false`를 리턴해요.
@@ -155,9 +155,9 @@ const mouse = {
};
```
-- A: `mouse.bird.size` 은 유효하지 않아요
-- B: `mouse[bird.size]` 은 유효하지 않아요
-- C: `mouse[bird["size"]]` 은 유효하지 않아요
+- A: `mouse.bird.size` 는 유효하지 않아요
+- B: `mouse[bird.size]` 는 유효하지 않아요
+- C: `mouse[bird["size"]]` 는 유효하지 않아요
- D: 이 모든 것들은 유효해요.
정답
@@ -167,7 +167,7 @@ const mouse = {
JavaScript에서, 모든 객체 키는 문자열이에요 (심볼이 아닌 한). 비록 그것을 문자열 _형_ 으로 입력하지 않아도, 항상 내부적으로 문자열로 변환돼요.
-JavaScript는 문장을 해석(또는 박스 해제)해요. 대괄호 표기를 사용하면, 첫 번째 열린 대괄호 `[`를 보고 닫힌 대괄호 `]`를 찾을 때까지 진행해요. 그때에 만, 그 문장을 평가할 거예요.
+JavaScript는 문장을 해석(또는 박스 해제)해요. 대괄호 표기를 사용하면, 첫 번째 열린 대괄호 `[`를 보고 닫힌 대괄호 `]`를 찾을 때까지 진행해요. 그때에만, 그 문장을 평가할 거예요.
`mouse[bird.size]`: 먼저 `"small"`인 `bird.size`를 평가해요. `mouse["small"]` 은 `true`를 리턴해요.
@@ -200,7 +200,7 @@ console.log(d.greeting);
#### 정답: A
-JavaScript에서, 모든 객체는 서로 동일하게 설정하면 _참조_ 에 따라 상호작용 해요.
+JavaScript에서, 모든 객체는 서로 동일하게 설정하면 _참조_ 에 따라 상호작용해요.
우선 변수 `c`는 객체에 대한 값을 유지해요. 그 후, `c`와 동일한 객체 참조를 `d`에 할당해요.
@@ -237,7 +237,7 @@ console.log(b === c);
`new Number()`는, 내장 함수 생성자예요. 숫자처럼 보이지만, 실제로는 숫자가 아니에요: 많은 추가 특성이 있고 그것은 객체예요.
-`==`연산자를 사용할 때, 그건 같은 _값_ 을 가지고 있는지 여부만 확인해요. 그것들은 모두`3`의 값을 가지고 있으므로, `true`를 리턴해요.
+`==`연산자를 사용할 때, 그건 같은 _값_ 을 가졌는지 여부만 확인해요. 그것들은 모두`3`의 값을 가지고 있으므로, `true`를 리턴해요.
그러나, `===`연산자를 사용할 때, 값 _과_ 형 둘 다 같아야 해요. 이건 아니에요: `new Number()`는 숫자가 아니에요. **객체**에요. 그래서 둘 다 `false`를 리턴해요.
@@ -298,7 +298,7 @@ console.log(greetign);
#### 정답: A
-역 객체에 빈 객체를 방금 만들었기 때문에, 객체는 출력되요. `greeting`을 `greettign`으로 잘못 입력했을 경우, JS 인터프리터는 실제로 이것을 `global.greettign = {}` (또는 브라우저의 `window.greetign = {}`) 라고 간주해요.
+역 객체에 빈 객체를 방금 만들었기 때문에, 객체는 출력돼요. `greeting`을 `greettign`으로 잘못 입력했을 경우, JS 인터프리터는 실제로 이것을 `global.greettign = {}` (또는 브라우저의 `window.greetign = {}`) 라고 간주해요.
이것을 피하기 위해서, `"use strict"`를 사용할 수 있어요. 이렇게 하면 변수를 어떤 것과 동일하게 설정하기 전에 변수를 선언했는지 확인할 수 있어요.
@@ -370,7 +370,7 @@ Person.prototype.getFullName = function() {
};
```
-`member.getFullName()`은 작동해요. 이것은 왜 유익할까요? 이 메소드를 생성자 자체에 추가했다고 할게요. 아마도 모든 `Person` 인스턴스는 이 메소드를 필요로 하지 않을 수도 있어요. 그 경우 그들은 계속해서 속성을 갖고 있기 때문에, 각각의 인스턴스를 위한 메모리 공간을 소비하게 되어, 많은 메모리 공간을 낭비하게 될 거예요. 대신에, 프로토타입을 추가하는 것만으로, 메모리의 한 지점을 가지지만, 모든 것들은 그것에 접근 할 수 있어요.
+`member.getFullName()`은 작동해요. 이것은 왜 유익할까요? 이 메소드를 생성자 자체에 추가했다고 할게요. 아마도 모든 `Person` 인스턴스는 이 메소드가 필요하지 않을 수도 있어요. 그 경우 그들은 계속해서 속성을 갖고 있기 때문에, 각각의 인스턴스를 위한 메모리 공간을 소비하게 되어, 많은 메모리 공간을 낭비하게 될 거예요. 대신에, 프로토타입을 추가하는 것만으로, 메모리의 한 지점을 가지지만, 모든 것들은 그것에 접근할 수 있어요.
@@ -402,7 +402,7 @@ console.log(sarah);
#### 정답: A
-`sarah`에게 `new`키워드를 사용하지 않았어요. `new`를 사용한 경우, 이것은 우리가 만든 새로운 빈 객체를 참조해요. 그러나, `new`를 추가하지 않으면 **전역변수**를 참조해요!
+`sarah`에게 `new` 키워드를 사용하지 않았어요. `new`를 사용한 경우, 이것은 우리가 만든 새로운 빈 객체를 참조해요. 그러나, `new`를 추가하지 않으면 **전역변수**를 참조해요!
`this.firstName`은 `"Sarah"`이고, `this.lastName`은 `"Smith"`이리고 말했었어요. (그렇지만) 우리는 실제로 한 일은 `global.firstName = 'Sarah'` 그리고 `global.lastName = 'Smith'`를 정의하는 것이에요. `sarah` 자체는 `undefined`로 남아있어요.
@@ -423,7 +423,7 @@ console.log(sarah);
#### 정답: D
-**capturing** 단계 동안에, 이벤트는 조상요소를 거쳐 목표 요소까지 내려가요. 그런 다음 **target** 요소에 도달하고, **bubbling**이 시작돼요.
+**capturing** 단계 동안에, 이벤트는 조상 요소를 거쳐 목표 요소까지 내려가요. 그런 다음 **target** 요소에 도달하고, **bubbling**이 시작돼요.
@@ -442,7 +442,7 @@ console.log(sarah);
#### 정답: B
-**기본 객체**를 제외한, 모든 객체는 프로토타입을 가져요. 기본 객체는 사용자에 의해 만들어지거나 `new`키워드를 사용하여 만들어져요. 기본 객체는 `.toString`와 같은 몇 개의 메소드와 속성에 접근할 수 있어요. 이것이 내장 JavaScript 메소드를 사용할 수 있는 이유죠! 이러한 모든 메소드는 프로토 타입에서 이용할 수 있어요. JavaScript가 당신의 객체를 직접 찾을 수 없더라도, 당신이 접근할 수 있도록 프로토타입 체인으로 내려가서 찾을거에요.
+**기본 객체**를 제외한, 모든 객체는 프로토타입을 가져요. 기본 객체는 사용자에 의해 만들어지거나 `new` 키워드를 사용하여 만들어져요. 기본 객체는 `.toString`과 같은 몇 개의 메소드와 속성에 접근할 수 있어요. 이것이 내장 JavaScript 메소드를 사용할 수 있는 이유죠! 이러한 모든 메소드는 프로토타입에서 이용할 수 있어요. JavaScript가 당신의 객체를 직접 찾을 수 없더라도, 당신이 접근할 수 있도록 프로토타입 체인으로 내려가서 찾을 거에요.
@@ -507,7 +507,7 @@ console.log(number);
1. 값 증가 (number는 지금 `2`이에요)
2. 값 리턴 (이것은 `2`을 리턴해요)
-이건 `0 2 2`을 리턴해요.
+이건 `0 2 2`를 리턴해요.
@@ -538,7 +538,7 @@ getPersonInfo`${person} is ${age} years old`;
#### 정답: B
-태그드 템플릿 리터럴을 사용하는 경우, 첫 번재 인수의 값은 항상 문자열 값의 배열이에요. 나머지 인수는 식을 통과한 값을 얻어요.
+태그드 템플릿 리터럴을 사용하는 경우, 첫 번째 인수의 값은 항상 문자열 값의 배열이에요. 나머지 인수는 식을 통과한 값을 얻어요.
@@ -570,9 +570,9 @@ checkAge({ age: 18 });
#### 정답: C
-동등성을 테스트할 때, 원시형은 그 _값_ 에 따라 비교되며, 객체는 그들의 _참조_ 에 따라 비교돼요. JavaScript 객체가 메모리 내의 같은 장소를 참조하고 있는지 여부를 확인해요.
+동등성을 테스트할 때, 원시형은 그 _값_ 에 따라 비교되며, 객체는 그들의 _참조_ 에 따라 비교돼요. JavaScript 객체가 메모리 내의 같은 장소를 참조하고 있는지를 확인해요.
-비교하고 있는 두개의 객체는 그것이 없어요: 파라미터로 전달된 객체와 동등성을 확인하기 위해 사용한 객체는 메모리 내의 다른 장소를 참조해요.
+비교하고 있는 두 개의 객체는 그것이 없어요: 파라미터로 전달된 객체와 동등성을 확인하기 위해 사용한 객체는 메모리 내의 다른 장소를 참조해요.
이것이 `{ age: 18 } === { age: 18 }` 그리고 `{ age: 18 } == { age: 18 }` 두 개 다 `false`를 리턴하는 이유죠.
@@ -630,7 +630,7 @@ getAge();
#### 정답: C
-`"use strict"`을 사용하면, 실수로 전역 변수를 선언하지 않게 할 수 있어요. `age`이라는 변수를 선언한 적이 전혀 없고, `"use strict"`을 사용하고 있으므로, 참조 에러를 던지게 될 거에요. 만약 `"use strict"`을 사용하지 않았다면, 이건 작동할 거에요, `age` 속성이 전역 객체에 추가된 것이기 때문이죠.
+`"use strict"`을 사용하면, 실수로 전역 변수를 선언하지 않게 할 수 있어요. `age`라는 변수를 선언한 적이 전혀 없고, `"use strict"`을 사용하고 있으므로, 참조 에러를 던지게 될 거예요. 만약 `"use strict"`을 사용하지 않았다면, 이건 작동할 거예요, `age` 속성이 전역 객체에 추가된 것이기 때문이죠.
@@ -653,7 +653,7 @@ const sum = eval("10*10+5");
#### 정답: A
-`eval` 문자열로서 통과된 코드를 평가해요. 이 경우와 같이 만약 그것이 표현식이라면, 표현식을 평가해요. 표현식은 `10 * 10 + 5`이에요. 이것은 숫자 `105`를 리턴해요.
+`eval` 문자열로서 통과된 코드를 평가해요. 이 경우와 같이 만약 그것이 표현식이라면, 표현 식을 평가해요. 표현 식은 `10 * 10 + 5`이에요. 이것은 숫자 `105`를 리턴해요.
@@ -668,7 +668,7 @@ sessionStorage.setItem("cool_secret", 123);
- A: 영원히, 데이터는 사라지지 않아요.
- B: 사용자가 탭을 닫을 때.
-- C: 사용자가 탭 뿐만 아니라, 브라우저 전체를 닫을 때.
+- C: 사용자가 탭뿐만 아니라, 브라우저 전체를 닫을 때.
- D: 사용자가 자신의 컴퓨터를 종료시켰을 때.
정답
@@ -678,7 +678,7 @@ sessionStorage.setItem("cool_secret", 123);
`sessionStorage`에 저장된 데이터는 _탭_ 을 닫은 후에 삭제돼요.
-만약 `localStorage`를 사용했다면, 예를 들어 `localStorage.clear()`를 호출하지 않는 한, 데이터는 영원할 거에요.
+만약 `localStorage`를 사용했다면, 예를 들어 `localStorage.clear()`를 호출하지 않는 한, 데이터는 영원할 거예요.
@@ -704,7 +704,7 @@ console.log(num);
#### 정답: B
-`var`키워드를 사용하면, 같은 이름으로 복수의 변수를 선언할 수 있어요. 변수는 최신의 값을 유지해요.
+`var` 키워드를 사용하면, 같은 이름으로 복수의 변수를 선언할 수 있어요. 변수는 최신의 값을 유지해요.
블록 스코프의 `let` 또는 `const`에서는 할 수 없어요.
@@ -737,7 +737,7 @@ set.has(1);
모든 객체 키는(심볼 제외) 문자열로 직접 입력하지 않아도, 내부적으로는 문자열이에요. 이것이 `obj.hasOwnProperty('1')`도 true를 리턴하는 이유죠.
-set에서는 작동하지 않아요. set에는 `'1'`이 없어요: `set.has('1')`는 `false`를 리턴해요. 그것은 수형인 `1`을 가지고 있어, `set.has(1)`은 `true`를 리턴해요.
+set에서는 작동하지 않아요. set에는 `'1'`이 없어요: `set.has('1')`는 `false`를 리턴해요. 그것은 수형인 `1`을 가지고 있어, `set.has(1)`는 `true`를 리턴해요.
@@ -805,7 +805,7 @@ for (let i = 1; i < 5; i++) {
#### 정답: C
-`continue` 표현식은 특정 조건이 `true`를 리턴하면 반복 처리를 건너뛰어요.
+`continue` 표현 식은 특정 조건이 `true`를 리턴하면 반복 처리를 건너뛰어요.
@@ -834,7 +834,7 @@ name.giveLydiaPizza();
#### 정답: A
-`String`은 내장 생성자로 속성을 추가할 수 있어요. 단지 프로토타입이라는 메소드를 추가했어요. 원시형 문자열은 문자열 프로토타입 함수에 의해 생성된 문자열 객체로 자동 변환돼요. 그래서, 모든 문자열(문자열 객체)는 그 메소드에 접근할 수 있어요!
+`String`은 내장 생성자로 속성을 추가할 수 있어요. 단지 프로토타입이라는 메소드를 추가했어요. 원시형 문자열은 문자열 프로토타입 함수에 의해 생성된 문자열 객체로 자동 변환돼요. 그래서, 모든 문자열(문자열 객체)은 그 메소드에 접근할 수 있어요!
@@ -864,11 +864,11 @@ console.log(a[b]);
#### 정답: B
-객체 키는 자동으로 문자열로 변환돼요. 객체 `a`의 키 값으로 `123`를 세팅하려고 해요.
+객체 키는 자동으로 문자열로 변환돼요. 객체 `a`의 키 값으로 `123`을 세팅하려고 해요.
그러나, 객체를 문자열화 하면 `"[Object object]"`가 돼요. 그래서 여기서 말하고자 하는 건 `a["Object object"] = 123`이라는 거예요. 그 후, 같은 일을 다시 시도해요. `c`는 암묵적으로 문자열화 한 다른 객체에요. 그래서 `a["Object object"] = 456`이 돼요.
-그 후, `a[b]`는 출력하면 실제로는 `a["Object object"]`에요. 단지 `456`를 설정했기 때문에, `456`를 리턴해요.
+그 후, `a[b]`는 출력하면 실제로는 `a["Object object"]`에요. 단지 `456`을 설정했기 때문에, `456`을 리턴해요.
@@ -913,7 +913,7 @@ _callback_ 이 WebAPI에 푸시된 후, `setTimeout`함수 자체(callback이
-WebAPI는 준비가 될 때마다 stack에 항목을 추가할 수 없어요. 대신에, _queue_ 라고 불리는 것에 callback함수를 푸시해요.
+WebAPI는 준비가 될 때마다 stack에 항목을 추가할 수 없어요. 대신에, _queue_ 라고 불리는 것에 callback 함수를 푸시해요.
@@ -977,7 +977,7 @@ WebAPI는 준비가 될 때마다 stack에 항목을 추가할 수 없어요.
#### 정답: A
-`p`를 클릭하면, 2개의 로그를 볼 수 있어요: `p` 그리고 `div`. 이벤트의 전파 중에는 3 단계가 있어요: 캡처링, 타겟, 버블링. 기본적으로, 이벤트 핸들러는 버블링 단계에서 시작돼요. (`useCapture`를 `true`로 설정하지 않는 한). 가장 깊게 중첩된 요소로부터 바깥쪽으로 나가요.
+`p`를 클릭하면, 2개의 로그를 볼 수 있어요: `p` 그리고 `div`. 이벤트의 전파 중에는 3단계가 있어요: 캡처링, 타겟, 버블링. 기본적으로, 이벤트 핸들러는 버블링 단계에서 시작돼요. (`useCapture`를 `true`로 설정하지 않는 한). 가장 깊게 중첩된 요소로부터 바깥쪽으로 나가요.
@@ -1007,7 +1007,7 @@ sayHi.bind(person, 21);
#### 정답: D
-두 개 모두, `this`키워드를 참조하고자 하는 객체로 보낼 수 있어요. 그러나, `.call`은 _즉시 실행돼요_!
+두 개 모두, `this` 키워드를 참조하고자 하는 객체로 보낼 수 있어요. 그러나, `.call`은 _즉시 실행돼요_!
`.bind.`는 함수의 _복사본_ 을 리턴하지만, 바인딩 콘텍스트죠! 이건 즉시 실행되지 않아요.
@@ -1075,7 +1075,7 @@ undefined;
- `''` (빈 문자열)
- `false`
-`new Number` 그리고 `new Boolean`와 같은 생성자 함수는 참 같은 값이에요.
+`new Number` 그리고 `new Boolean`과 같은 생성자 함수는 참 같은 값이에요.
@@ -1098,7 +1098,7 @@ console.log(typeof typeof 1);
#### 정답: B
-`typeof 1` 은 `"number"`을 리턴해요.
+`typeof 1` 은 `"number"`를 리턴해요.
`typeof "number"`은 `"string"`을 리턴해요.
@@ -1124,7 +1124,7 @@ console.log(numbers);
#### 정답: C
-배열의 길이를 초과한 값을 배열의 요소로 설정하고자 할 때, JavaScript는 "empty slots"이라고 불리는 것을 생성해요. 이것은 실제로 `undefined`의 값을 가지고 있지만, 다음과 같은 것을 보게 될 거에요:
+배열의 길이를 초과한 값을 배열의 요소로 설정하고자 할 때, JavaScript는 "empty slots"라고 불리는 것을 생성해요. 이것은 실제로 `undefined`의 값을 가지고 있지만, 다음과 같은 것을 보게 될 거예요:
`[1, 2, 3, 7 x empty, 11]`
@@ -1166,7 +1166,7 @@ depending on where you run it (it's different for every browser, node, etc.)
후에, 블록-스코프 변수는 `1`로 설정하고, 변수 `y`의 값을 설정해요. 여기서, 블록-스코프의 변수 `x`를 출력하는데, 이것은 `1`이에요.
-`catch` 블록 밖에서, `x`는 여전히 `undefined`이고 `y`는 `2`이에요. `catch` 블록 밖에서 `console.log(x)`를 출력하면, `undefined`을 리턴하고. 그리고 `y`는 `2`를 리턴해요.
+`catch` 블록 밖에서, `x`는 여전히 `undefined`이고 `y`는 `2`이에요. `catch` 블록 밖에서 `console.log(x)`를 출력하면, `undefined`를 리턴하고. 그리고 `y`는 `2`를 리턴해요.
@@ -1189,7 +1189,7 @@ JavaScript는 원시형과 객체만 가지고 있어요.
원시형은 `boolean`, `null`, `undefined`, `bigint`, `number`, `string` 그리고 `symbol`이 있어요.
-원시형과 객체를 구별하는 법은 원시형에는 속성이나 메소드가 없어요. 그러나 `'foo'.toUpperCase()`는 `'FOO'`로 평가되어, `TypeError`의 결과가 되지 않아요. 문자열과 같은 원시형이 속성 또는 메소드에 접근하려고 할 때, JavaScript는 래퍼 클래스 중 하나인 `String`을 사용하여 암묵적으로 감싸고, 표현식이 평가된 후 즉시 래퍼를 폐기하기 때문이에요. `null` 그리고 `undefined`를 제외한 모든 원시형은 이러한 행동을 합니다.
+원시형과 객체를 구별하는 법은 원시형에는 속성이나 메소드가 없어요. 그러나 `'foo'.toUpperCase()`는 `'FOO'`로 평가되어, `TypeError`의 결과가 되지 않아요. 문자열과 같은 원시형이 속성 또는 메소드에 접근하려고 할 때, JavaScript는 래퍼 클래스 중 하나인 `String`을 사용하여 암묵적으로 감싸고, 표현 식이 평가된 후 즉시 래퍼를 폐기하기 때문이에요. `null` 그리고 `undefined`를 제외한 모든 원시형은 이러한 행동을 합니다.
@@ -1217,7 +1217,7 @@ JavaScript는 원시형과 객체만 가지고 있어요.
#### 정답: C
-`[1, 2]`은 초기값이에요. 이것이 최초의 값으로, 제일 처음의 `acc`의 값이에요. 처음 라운드 동안에 `acc`은 `[1,2]`이며, `cur`은 `[0, 1]`이에요. 그것들을 연결하면 결과적으로 `[1, 2, 0, 1]`이 돼요.
+`[1, 2]`은 초깃값이에요. 이것이 최초의 값으로, 제일 처음의 `acc`의 값이에요. 처음 라운드 동안에 `acc`는 `[1,2]`이며, `cur`은 `[0, 1]`이에요. 그것들을 연결하면 결과적으로 `[1, 2, 0, 1]`이 돼요.
그 후, `[1, 2, 0, 1]`은 `acc`이고, `[2, 3]`은 `cur`이 에요. 그것들을 연결하면 `[1, 2, 0, 1, 2, 3]`을 얻게 돼요.
@@ -1244,9 +1244,9 @@ JavaScript는 원시형과 객체만 가지고 있어요.
#### 정답: B
-`null`은 거짓 같은 값이에요. `!null`은 `true`를 리턴해요. `!true`은 `false`를 리턴해요.
+`null`은 거짓 같은 값이에요. `!null`은 `true`를 리턴해요. `!true`는 `false`를 리턴해요.
-`""` 은 거짓 같은 값이에요. `!""`은 `true`를 리턴해요. `!true`은 `false`를 리턴해요.
+`""` 은 거짓 같은 값이에요. `!""`은 `true`를 리턴해요. `!true`는 `false`를 리턴해요.
`1`은 참 같은 값이에요. `!1`은 `false`를 리턴해요. `!false`는`true`를 리턴해요.
@@ -1327,7 +1327,7 @@ console.log(gen.next().value);
보통의 함수는 호출 후에 중단할 수 없어요. 하지만, 제너레이터 함수는 중간에 "멈췄다가", 나중에 중단된 부분부터 계속할 수 있어요. 제너레이터 함수는 `yield` 키워드를 만날 때마다, yield 뒤에 지정된 값을 넘겨줘요. 제너레이터 함수에서는 값을 _리턴_ 하지 않고, _넘겨준다_ 는 것을 유의하세요.
-우선, 제너레이터 함수에서 `i`를 `10`로 초기화해요. `next()` 메소드를 사용해 제너레이터 함수를 호출해요. 처음에 제너레이터 함수를 호출하면, `i`은 `10`이에요. 첫 번째 `yield` 키워드를 만났어요: 그것은 `i`의 값을 넘겨줘요. 이제 제너레이터는 "멈추고", `10`을 출력해요.
+우선, 제너레이터 함수에서 `i`를 `10`으로 초기화해요. `next()` 메소드를 사용해 제너레이터 함수를 호출해요. 처음에 제너레이터 함수를 호출하면, `i`은 `10`이에요. 첫 번째 `yield` 키워드를 만났어요: 그것은 `i`의 값을 넘겨줘요. 이제 제너레이터는 "멈추고", `10`을 출력해요.
그 후, `next()` 메소드를 사용해 다시 한번 함수를 호출해요. `i`는 여전히 `10`이에요. 이제, 다음 `yield` 키워드를 만나 `i * 2`를 넘겨줘요. `i`는 `10`이므로, `10 * 2`, 즉 `20`을 리턴해요. 결과는 `10, 20`이에요.
@@ -1360,7 +1360,7 @@ Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
#### 정답: B
-복수의 프로미스를 `Promise.race` 메소드에 넘겨주면, _최초_ 의 프로미스를 해결/거부 해요. `setTimeout` 메소드에 타이머를 전달해요: 첫번째 프로미스(`firstPromise`)에는 500ms, 두번째 프로미스(`secondPromise`)에는 100ms. 이것은 `'two'`의 값을 가진 `secondPromise`가 최초로 해결한다는 것을 의미해요. 이제 `res`는 `'two'`의 값을 유지하고 출력되요.
+복수의 프로미스를 `Promise.race` 메소드에 넘겨주면, _최초_ 의 프로미스를 해결/거부해요. `setTimeout` 메소드에 타이머를 전달해요: 첫 번째 프로미스(`firstPromise`)에는 500ms, 두 번째 프로미스(`secondPromise`)에는 100ms. 이것은 `'two'`의 값을 가진 `secondPromise`가 최초로 해결한다는 것을 의미해요. 이제 `res`는 `'two'`의 값을 유지하고 출력돼요.
@@ -1387,19 +1387,19 @@ console.log(members);
#### 정답: D
-우선, 변수 `person`의 값을 `name`속성을 가진 객체로 선언해요.
+우선, 변수 `person`의 값을 `name` 속성을 가진 객체로 선언해요.
-그 후, `members`라는 변수를 선언해요. 배열의 첫 번째 요소에 `person`변수의 값을 대입해요. 서로를 같게 설정하면 _참조_ 에 의해 상호작용해요. 어떤 변수에서 다른 변수로 참조를 할당하면, 그 참조의 _복사본_ 을 만들어요. (그들은 _같은_ 참조를 가지고 있지 않다는 것을 유의하세요!)
+그 후, `members`라는 변수를 선언해요. 배열의 첫 번째 요소에 `person` 변수의 값을 대입해요. 서로를 같게 설정하면 _참조_ 에 의해 상호작용해요. 어떤 변수에서 다른 변수로 참조를 할당하면, 그 참조의 _복사본_ 을 만들어요. (그들은 _같은_ 참조를 가지고 있지 않다는 것을 유의하세요!)
-그리고, 변수 `person`를 `null`로 설정해요.
+그리고, 변수 `person`을 `null`로 설정해요.
-배열의 첫 번째 요소는 객체에 대한 다른 (복사된) 참조를 가지고 있기 때문에, `person` 변수의 값만 변경하고, 배열의 첫번째 요소는 변경할 수 없어요. `members`의 첫 번째 요소는 여전히 원본 객체에 대한 참조를 유지하고 있어요. `members` 배열을 출력할 때, 첫 번째 요소는 여전히 객체의 값을 유지하고 있어 로그가 출력돼요.
+배열의 첫 번째 요소는 객체에 대한 다른 (복사된) 참조를 가지고 있기 때문에, `person` 변수의 값만 변경하고, 배열의 첫 번째 요소는 변경할 수 없어요. `members`의 첫 번째 요소는 여전히 원본 객체에 대한 참조를 유지하고 있어요. `members` 배열을 출력할 때, 첫 번째 요소는 여전히 객체의 값을 유지하고 있어 로그가 출력돼요.
@@ -1429,7 +1429,7 @@ for (const item in person) {
#### 정답: B
-`for-in` 루프를 사용하면, 객체 키를 통해서 반복할 수 있는데, 이경우에서는 `name` 그리고 `age`에요. 내부적으로, 객체 키는 문자열이에요 (심볼이 아니라면 말이죠). 모든 루프에서, `item`의 값은 반복되어 있는 현재의 키 값으로 설정해요. 우선, `item`은 `name`로 출력돼요. 그 후, `item`은 `age`로 출력돼요.
+`for-in` 루프를 사용하면, 객체 키를 통해서 반복할 수 있는데, 이 경우에서는 `name` 그리고 `age`에요. 내부적으로, 객체 키는 문자열이에요 (심볼이 아니라면 말이죠). 모든 루프에서, `item`의 값은 반복된 현재의 키 값으로 설정해요. 우선, `item`은 `name`으로 출력돼요. 그 후, `item`은 `age`로 출력돼요.
@@ -1452,11 +1452,11 @@ console.log(3 + 4 + "5");
#### 정답: B
-연산자 결합성은 왼쪽에서 오른쪽 또는 오른쪽에서 왼쪽으로 컴파일러가 표현식을 평가하는 순서가 되요. 이것은 연산자가 _같은_ 우선순위를 가진 경우에만 해당되요. 연산자의 종류는 한개뿐이에요: `+`. 게다가, 결합성은 왼쪽에서 오른쪽이에요.
+연산자 결합성은 왼쪽에서 오른쪽 또는 오른쪽에서 왼쪽으로 컴파일러가 표현 식을 평가하는 순서가 돼요. 이것은 연산자가 _같은_ 우선순위를 가진 경우에만 해당돼요. 연산자의 종류는 한 개뿐이에요: `+`. 게다가, 결합성은 왼쪽에서 오른쪽이에요.
-처음으로 `3 + 4`가 평가되요. 결과는 숫자 `7`이에요.
+처음으로 `3 + 4`가 평가돼요. 결과는 숫자 `7`이에요.
-`7 + '5'`의 결과는 강제성 때문에 `"75"`가 돼요. JavaScript는 숫자 `7`을 문자열로 변환하고, (자세한 내용은)질문 15를 보세요. `+` 연산자를 사용해서 두 개의 문자열을 연결할 수 있어요. `"7" + "5"`의 결과는 `"75"`이에요.
+`7 + '5'`의 결과는 강제성 때문에 `"75"`가 돼요. JavaScript는 숫자 `7`을 문자열로 변환하고, (자세한 내용은) 질문 15를 보세요. `+` 연산자를 사용해서 두 개의 문자열을 연결할 수 있어요. `"7" + "5"`의 결과는 `"75"`이에요.
@@ -1479,9 +1479,9 @@ const num = parseInt("7*6", 10);
#### 정답: C
-문자열의 첫 번째 숫자만 리턴돼요. _진법_ 에 근거하여 (파싱 하고자 하는 숫자의 기준을 명시하기 위한 두 번째 인수: 기본적인 10진수, 6진수, 8진수, 2진수 등), `parseInt`는 문자열 내의 문자가 타당한지 여부를 확인해요. 진수에 유효한 숫자가 아닌 문자를 만나면, 파싱을 멈추고, 다음 문자를 무시해요.
+문자열의 첫 번째 숫자만 리턴돼요. _진법_ 에 근거하여 (파싱하고자 하는 숫자의 기준을 명시하기 위한 두 번째 인수: 기본적인 10진수, 6진수, 8진수, 2진수 등), `parseInt`는 문자열 내의 문자가 타당한지 여부를 확인해요. 진수에 유효한 숫자가 아닌 문자를 만나면, 파싱을 멈추고, 다음 문자를 무시해요.
-`*`은 유요한 숫자가 아니에요. `"7"`만 십진수의 `7`으로 파싱 돼요. 이제 `num`은 `7`의 값을 유지해요.
+`*`은 유효한 숫자가 아니에요. `"7"`만 십진수의 `7`로 파싱 돼요. 이제 `num`은 `7`의 값을 유지해요.
@@ -1507,9 +1507,9 @@ const num = parseInt("7*6", 10);
#### 정답: C
-배열을 매핑할 때, `num`의 값은 헌재 순환하고 있는 요소예요. 이 경우, 요소는 숫자이기 때문에, if문의 조건 `typeof num === "number"`는 `true`를 리턴해요. map 합수는 새로운 배열을 만들고 함수에서 리턴된 값을 삽입해요.
+배열을 매핑할 때, `num`의 값은 헌재 순환하고 있는 요소예요. 이 경우, 요소는 숫자이기 때문에, if 문의 조건 `typeof num === "number"`는 `true`를 리턴해요. map 합수는 새로운 배열을 만들고 함수에서 리턴된 값을 삽입해요.
-그러나, 값을 리턴하지 않아요. 함수는 값을 리턴하지 않을 때, `undefined`을 리턴해요. 배열에서의 모든 요소에 대해 블록 함수가 호출되기 때문에, 각 요소에 대해 `undefined`을 리턴해요.
+그러나, 값을 리턴하지 않아요. 함수는 값을 리턴하지 않을 때, `undefined`를 리턴해요. 배열에서의 모든 요소에 대해 블록 함수가 호출되기 때문에, 각 요소에 대해 `undefined`를 리턴해요.
@@ -1542,11 +1542,11 @@ console.log(person, birthYear);
#### 정답: A
-인수들의 값이 객체가 아닌 한 _값_ 에 의해 전달되요. 그 후 _참조_ 에 의해 전달되요. `birthYear`는 객체가 아니라 문자열이기 때문에 값에 의해 전달되요. 값으로 전달하면 값의 _복사본_ 이 만들어 져요(질문 46을 보세요).
+인수들의 값이 객체가 아닌 한 _값_ 에 의해 전달돼요. 그 후 _참조_ 에 의해 전달돼요. `birthYear`는 객체가 아니라 문자열이기 때문에 값에 의해 전달돼요. 값으로 전달하면 값의 _복사본_ 이 만들어져요(질문 46을 보세요).
-변수 `birthYear`는 `"1997"`값에 대한 참조를 가져요. 인수 `year` 또한 `"1997"`에 대한 참조를 가지지만, `birthYear`가 가진 참조값과는 달라요. `year`에 `"1998"`을 대입하여 `year`의 값을 업데이트할 때, `year`의 값만 업데이트해요. `birthYear`는 여전히 `"1997"`이에요.
+변수 `birthYear`는 `"1997"`값에 대한 참조를 가져요. 인수 `year` 또한 `"1997"`에 대한 참조를 가지지만, `birthYear`가 가진 참조 값과는 달라요. `year`에 `"1998"`을 대입하여 `year`의 값을 업데이트할 때, `year`의 값만 업데이트해요. `birthYear`는 여전히 `"1997"`이에요.
-`person`의 값은 객체예요. 인수 `member`는 _같은_ 객체의 (복사된) 참조값을 가져요. `member`객체의 속성이 갖는 참조를 변경하면, 두 개 모두 같은 객체를 참조 값을 가지고 있기 때문에, `person`의 값 또한 변경돼요. 이제 `person`'의 `name` 속성은 값 `"Lydia"`에요.
+`person`의 값은 객체예요. 인수 `member`는 _같은_ 객체의 (복사된) 참조 값을 가져요. `member`객체의 속성이 갖는 참조를 변경하면, 두 개 모두 같은 객체를 참조 값을 가지고 있기 때문에, `person`의 값 또한 변경돼요. 이제 `person`'의 `name` 속성은값 `"Lydia"`에요.
@@ -1582,7 +1582,7 @@ sayHi();
#### 정답: D
-`throw`문을 사용해, 커스텀 에러를 만들 수 있어요. 이 표현식을 사용해, 예외를 던질 수 있어요. 예외는 string, a number, a boolean or an object이 될 수 있어요. 이 경우, 예외는 `'Hello world'` 문자열이에요.
+`throw`문을 사용해, 커스텀 에러를 만들 수 있어요. 이 표현 식을 사용해, 예외를 던질 수 있어요. 예외는 string, a number, a boolean or an object이 될 수 있어요. 이 경우, 예외는 `'Hello world'` 문자열이에요.
`catch` 문을 사용해, `try` 블록에서 예외가 던져졌을 경우에 무엇을 할지 명시할 수 있어요. 예외가 던져졌어요: 문자열 `'Hello world'`. `e`는 이제 문자열이고, 그것을 출력해요. 결과는 `'Oh an error: Hello world'`예요.
@@ -1613,7 +1613,7 @@ console.log(myCar.make);
#### 정답: B
-속성을 리턴할 때, 속성 값은 생성자에 설정한 값이 아닌, _리턴된_ 값과 같아요. `"Maserati"` 문자열을 리턴하기 때문에, `myCar.make`는 `"Maserati"`에요.
+속성을 리턴할 때, 속성값은 생성자에 설정한 값이 아닌, _리턴된_ 값과 같아요. `"Maserati"` 문자열을 리턴하기 때문에, `myCar.make`는 `"Maserati"`에요.
@@ -1650,7 +1650,7 @@ let x = y;
`y`에 `10`을 대입하면, 실제로는 전역 객체에 속성 `y`를 추가해요(브라우저에서는 `window`, Node에서는 `global`). 브라우저에서, `window.y`는 이제 `10`이에요.
-그 후, 변수 `x`를 `10`인 `y`를 값으로 선언해요. `let`키워드로 선언된 변수는 _블록 스코프_ 로, 선언된 블록 내에서만 정의돼요: 이경우 즉시 호출 함수예요(IIFE). `typeof`연산자를 사용할 때, 피연산자 `x`는 정의되지 않았어요: 선언된 블록 밖에서 접근하려 했어요. 이것은 `x`가 선언되지 않음을 의미해요. 값을 할당하거나 선언하지 않은 변수는 `"undefined"` 형이에요. `console.log(typeof x)`는 `"undefined"`를 리턴해요.
+그 후, 변수 `x`를 `10`인 `y`를 값으로 선언해요. `let`키워드로 선언된 변수는 _블록 스코프_ 로, 선언된 블록 내에서만 정의돼요: 이 경우 즉시 호출 함수예요(IIFE). `typeof`연산자를 사용할 때, 피연산자 `x`는 정의되지 않았어요: 선언된 블록 밖에서 접근하려 했어요. 이것은 `x`가 선언되지 않음을 의미해요. 값을 할당하거나 선언하지 않은 변수는 `"undefined"` 형이에요. `console.log(typeof x)`는 `"undefined"`를 리턴해요.
그러나, `y`를 `10`으로 설정할 때 전역 변수 `y`를 만들었어요. 이 값은 코드 내 어디에서나 접근할 수 있어요. `y`는 정의되었고, `"number"`형의 값을 유지해요. `console.log(typeof y)`는 `"number"`을 리턴해요.
@@ -1686,14 +1686,14 @@ pet.bark();
- C: `"Woof I am Mara"`, `undefined`
- D: `TypeError`, `TypeError`
-Answer
+정답
-#### Answer: A
+#### 정답: A
-프로토타입에서도 `delete`키워드를 사용해, 객체로부터 속성을 삭제할 수 있어요. 프로토타입에서 속성을 삭제하면, 프로토타입 체인에서 더 이상 사용할 수 없게 돼요. 이경우, `bark`함수는 `delete Dog.prototype.bark` 후에 프로토타입에서 더 이상 사용할 수 없게 되지만, 그래도 여전히 그것에 접근하려고 해요.
+프로토타입에서도 `delete`키워드를 사용해, 객체로부터 속성을 삭제할 수 있어요. 프로토타입에서 속성을 삭제하면, 프로토타입 체인에서 더는 사용할 수 없게 돼요. 이 경우, `bark` 함수는 `delete Dog.prototype.bark` 후에 프로토타입에서 더는 사용할 수 없게 되지만, 그래도 여전히 그것에 접근하려고 해요.
-함수가 아닌 것을 호출하려고 할 때, `TypeError`가 던져져요. 이경우 `pet.bark`은 `undefined`이기 때문에, `TypeError: pet.bark is not a function`예요.
+함수가 아닌 것을 호출하려고 할 때, `TypeError`가 던져져요. 이 경우 `pet.bark`는 `undefined`이기 때문에, `TypeError: pet.bark is not a function`예요.
@@ -1713,12 +1713,12 @@ console.log(set);
- C: `{1, 1, 2, 3, 4}`
- D: `{1, 2, 3, 4}`
-Answer
+정답
-#### Answer: D
+#### 정답: D
-`Set`는 _unique_ 값의 집합 객체예요: 값은 set 내에서 단 한 번만 발생해요.
+`Set`은 _unique_ 값의 집합 객체예요: 값은 set 내에서 단 한 번만 발생해요.
중복 값 `1`을 가진 반복 가능한 `[1, 1, 2, 3, 4]`을 전달하기 때문에, 그들 중 하나는 삭제돼요. 이것은 결과적으로 `{1, 2, 3, 4}`돼요.
@@ -1749,14 +1749,14 @@ console.log(myCounter);
- C: `Error`
- D: `NaN`
-Answer
+정답
-#### Answer: C
+#### 정답: C
import 된 모듈은 _read-only_ 예요 : import 된 모듈은 수정할 수 없어요. export 한 모듈만 값을 변경할 수 있어요.
-`myCounter`의 값을 증가 시키려고 할 때, 에러를 던져요: `myCounter`은 read-only이고 수정할 수 없어요.
+`myCounter`의 값을 증가시키려고 할 때, 에러를 던져요: `myCounter`는 read-only이고 수정할 수 없어요.
@@ -1778,14 +1778,14 @@ console.log(delete age);
- C: `true`, `true`
- D: `undefined`, `undefined`
-Answer
+정답
-#### Answer: A
+#### 정답: A
`delete`연산자는 불린 값을 리턴해요: 성공적으로 삭제를 한 경우 `true`를, 그렇지 않다면 `false`를 리턴해요. 그러나, `var`, `const` 또는 `let` 키워드로 선언된 변수들은 `delete`연산자를 사용해서 삭제될 수 없어요.
-`name` 변수는 `const`키워드로 선언되었기 때문에, 삭제에 실패해요. `age`를 `21`로 설정할 때, 실제로는 `age`라는 속성을 전역 객체에 추가한 거죠. 이 방법으로 객체, 전역 객체의 속성들을 성공적으로 삭제할 수 있어요. `delete age`는 `true`을 리턴해요.
+`name` 변수는 `const`키워드로 선언되었기 때문에, 삭제에 실패해요. `age`를 `21`로 설정할 때, 실제로는 `age`라는 속성을 전역 객체에 추가한 거죠. 이 방법으로 객체, 전역 객체의 속성들을 성공적으로 삭제할 수 있어요. `delete age`는 `true`를 리턴해요.
@@ -1806,10 +1806,10 @@ console.log(y);
- C: `1`
- D: `[1]`
-Answer
+정답
-#### Answer: C
+#### 정답: C
구조 분해 할당을 통해 객체의 배열 또는 속성들로부터 변수를 해체할 수 있어요. 예를 들어:
@@ -1827,7 +1827,7 @@ console.log(y);
-이것은 `y`의 값은 숫자 `1`인 배열의 첫번째 값과 같다는 것을 의미하죠. `y`를 출력하면 `1`이 리턴돼요.
+이것은 `y`의 값은 숫자 `1`인 배열의 첫 번째 값과 같다는 것을 의미하죠. `y`를 출력하면 `1`이 리턴돼요.
@@ -1848,12 +1848,12 @@ console.log(admin);
- C: `{ admin: true, user: ["Lydia", 21] }`
- D: `{ admin: true }`
-Answer
+정답
-#### Answer: B
+#### 정답: B
-스프레드 연산자 `...`를 사용해 객체를 결합할 수 있어요. 이것은 하나의 객체의 키/값의 쌍들을 복사본들을 만들어, 다른 객체에 추가해요. 이 경우, `user` 객체의 복사 본들을 만들어, `admin` 객체에 추가해요. `admin` 객체는 이제 복사된 키/값의 쌍들이 들어있고, 결과는 `{ admin: true, name: "Lydia", age: 21 }`예요.
+스프레드 연산자 `...` 를 사용해 객체를 결합할 수 있어요. 이것은 하나의 객체의 키/값의 쌍들을 복사본들로 만들어, 다른 객체에 추가해요. 이 경우, `user` 객체의 복사본들을 만들어, `admin` 객체에 추가해요. `admin` 객체는 이제 복사된 키/값의 쌍들이 들어있고, 결과는 `{ admin: true, name: "Lydia", age: 21 }` 예요.
@@ -1876,14 +1876,14 @@ console.log(Object.keys(person));
- C: `{ name: "Lydia"}`, `["name", "age"]`
- D: `{ name: "Lydia"}`, `["age"]`
-Answer
+정답
-#### Answer: B
+#### 정답: B
`defineProperty`메소드로, 객체에 새로운 속성들을 추가하거나, 기존 것을 수정할 수 있어요. `defineProperty` 메소드를 사용해 객체의 속성을 추가할 때, 기본적으로 객체의 속성들은 _비 열거자_ 예요. `Object.keys`메소드는 모든 _열거자_ 객체의 속성 이름들을 리턴하는데, 이 경우는 `"name"` 뿐이에요.
-`defineProperty`를 사용해 추가된 속성들은 기본적으로 변경할 수 없어요. `writable`, `configurable` 그리고 `enumerable` 속성들을 사용해 덮어쓰기 할 수 있어요. `defineProperty`메소드의 방법은 객체에 추가할 속성들을 훨씬 더 정교 하게 제어하도록 해줘요.
+`defineProperty`를 사용해 추가된 속성들은 기본적으로 변경할 수 없어요. `writable`, `configurable` 그리고 `enumerable` 속성들을 사용해 덮어쓰기 할 수 있어요. `defineProperty`메소드의 방법은 객체에 추가할 속성들을 훨씬 더 정교하게 제어하도록 해줘요.
@@ -1908,16 +1908,16 @@ console.log(data);
- C: `"["level", "health"]"`
- D: `"{"username": "lydiahallie", "level":19, "health":90}"`
-Answer
+정답
-#### Answer: A
+#### 정답: A
-`JSON.stringify` 두번째 인수는 _replacer_ 예요. replacer는 함수 또는 배열 둘 중 하나가 될 수 있고, stringify 할 대상과 방법을 제어 할 수 있게 해줘요.
+`JSON.stringify` 두 번째 인수는 _replacer_ 예요. replacer는 함수 또는 배열 둘 중 하나가 될 수 있고, stringify 할 대상과 방법을 제어할 수 있게 해줘요.
-replacer가 _배열_ 이라면, 배열에 이름이 포함된 속성만 JSON 문자열에 추가될 거에요. 이 경우, 이름을 가진 `"level"` 그리고 `"health"`속성들만 포함되고, `"username"`은 제외되요. `data` 은 이제 `"{"level":19, "health":90}"`에요.
+replacer가 _배열_ 이라면, 배열에 이름이 포함된 속성만 JSON 문자열에 추가될 거에요. 이 경우, 이름을 가진 `"level"` 그리고 `"health"`속성들만 포함되고, `"username"`은 제외 돼요. `data` 은 이제 `"{"level":19, "health":90}"`에요.
-replacer가 _함수_ 라면, stringifying 할 객체의 모든 속성에 호출돼요. 이 함수로부터 리턴된 값은 JSON 문자열에 추가될 때 속성의 값이 될 거에요. 만약 값이 `undefined`라면, 이 속성은 JSON 문자열로부터 제외돼요.
+replacer가 _함수_ 라면, stringifying 할 객체의 모든 속성에 호출돼요. 이 함수로부터 리턴된 값은 JSON 문자열에 추가될 때 속성의 값이 될 거예요. 만약 값이 `undefined`라면, 이 속성은 JSON 문자열로부터 제외돼요.
@@ -1944,12 +1944,12 @@ console.log(num2);
- C: `11`, `11`
- D: `11`, `12`
-Answer
+정답
-#### Answer: A
+#### 정답: A
-단항 연산자 `++`는 _우선_ 피연산자의 값을 _리턴하고_, _그 후_ 피연산자의 값을 _증가해요_. `increaseNumber` 함수이 처음으로 리턴 한 `num`의 값은 `10` 이기 때문에, `num1`의 값은 `10`이고, 그 후엔 `num`의 값만 증가해요.
+단항 연산자 `++`는 _우선_ 피연산자의 값을 _리턴하고_, _그 후_ 피연산자의 값을 _증가해요_. `increaseNumber` 함수가 처음으로 리턴 한 `num`의 값은 `10` 이기 때문에, `num1`의 값은 `10`이고, 그 후엔 `num`의 값만 증가해요.
`num1`을 `increasePassedNumber`로 전달했기 때문에, `num2`는 `10`이에요. `number`는 `10`이에요(`num1`의 값은, 다시 한번, 단항 연산자가 `++`는 _우선_ 피연산자의 값을 _리턴하고_, _그 후_ 피연산자의 값을 _증가해요_. `number`의 값은 `10`이에요 즉, `num2`는 `10`이죠.
From b0255d8af25c1af8ad182e9154b277180353f1ef Mon Sep 17 00:00:00 2001
From: shooterRao
Date: Mon, 1 Jul 2019 23:10:34 +0800
Subject: [PATCH 132/881] Fix question 14 in README-zh_CN.md
---
README-zh_CN.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README-zh_CN.md b/README-zh_CN.md
index cb26343d..21740dc3 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -432,7 +432,7 @@ console.log(sarah)
#### 答案: B
-除了**基本对象**(base object),所有对象都有原型。基本对象可以访问一些方法和属性,比如 `.tostring`。这就是为什么你可以使用内置的 JavaScript 方法!所有这些方法在原型上都是可用的。虽然 JavaScript 不能直接在对象上找到这些方法,但 JavaScript 会沿着原型链找到它们,以便于你使用。
+除了**基本对象**(base object),所有对象都有原型。基本对象可以访问一些方法和属性,比如 `.toString`。这就是为什么你可以使用内置的 JavaScript 方法!所有这些方法在原型上都是可用的。虽然 JavaScript 不能直接在对象上找到这些方法,但 JavaScript 会沿着原型链找到它们,以便于你使用。
From d55f9f4b6cc822842585a67b70a866db17477e27 Mon Sep 17 00:00:00 2001
From: Jacob Herper
Date: Tue, 2 Jul 2019 15:44:23 +0100
Subject: [PATCH 133/881] Languages ordered
This is a proposal to bring the languages into alphabetical order and to standardise their format (all in their own language).
---
README.md | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index 500208b2..585fbae3 100644
--- a/README.md
+++ b/README.md
@@ -9,18 +9,18 @@ The answers are in the collapsed sections below the questions, simply click on t
List of available languages:
* [English](./README.md)
-* [中文版本](./README-zh_CN.md)
-* [Versión en español](./README-ES.md)
+* [العربية](./README_AR.md)
+* [اللغة العامية - Egyptian Arabic](./README_ar-EG.md)
+* [Bosanski](./README-bs_BS.md)
+* [Deutsch](./README-de_DE.md)
+* [Español](./README-ES.md)
* [日本語](./README-ja_JA.md)
* [한국어](./README-ko_KR.md)
+* [Português Brasil](./README_pt_BR.md)
* [Русский](./README_ru-RU.md)
-* [Western Balkan](./README-bs_BS.md)
-* [Deutsch](./README-de_DE.md)
-* [Tiếng Việt](./README-vi.md)
* [Українська мова](./README-ua_UA.md)
-* [Português Brasil](./README_pt_BR.md)
-* [العربية](./README_AR.md)
-* [اللغة العامية - Egyptian Arabic](./README_ar-EG.md)
+* [Tiếng Việt](./README-vi.md)
+* [中文版本](./README-zh_CN.md)
---
From 7fee122eb695b8511fcfb82cc893ebd159dce4ac Mon Sep 17 00:00:00 2001
From: Alexander Ivanov
Date: Wed, 3 Jul 2019 20:46:11 +0300
Subject: [PATCH 134/881] Russian. Updates 06/19
---
README_ru-RU.md | 323 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 315 insertions(+), 8 deletions(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index f0ab0df3..b8f8ab31 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -6,12 +6,21 @@
Ответы находятся в свернутой секции ниже вопросов. Просто нажми на "Ответ", чтобы развернуть. Удачи! :heart:
-[中文版本](./README-zh_CN.md)
-[Western Balkan](./README-bs_BS.md)
-[Deutsch](./README-de_DE.md)
-[Tiếng Việt](./README-vi.md)
-[日本語](./README-ja_JA.md)
-[Українська мова](./README-ua_UA.md)
+
+List of available languages:
+* [English](./README.md)
+* [中文版本](./README-zh_CN.md)
+* [Versión en español](./README-ES.md)
+* [日本語](./README-ja_JA.md)
+* [한국어](./README-ko_KR.md)
+* [Русский](./README_ru-RU.md)
+* [Western Balkan](./README-bs_BS.md)
+* [Deutsch](./README-de_DE.md)
+* [Tiếng Việt](./README-vi.md)
+* [Українська мова](./README-ua_UA.md)
+* [Português Brasil](./README_pt_BR.md)
+* [العربية](./README_AR.md)
+* [اللغة العامية - Egyptian Arabic](./README_ar-EG.md
---
@@ -1037,7 +1046,6 @@ typeof sayHi();
Функция `sayHi` возвращает значение, возвращаемое из немедленно вызываемого функционального выражения (IIFE). Результатом является `0` типа `"number"`.
Для информации: в JS 7 встроенных типов: `null`, `undefined`, `boolean`, `number`, `string`, `object`, и `symbol`. `"function"` не является отдельным типом, т.к. функции являются объектами типа `"object"`.
-
@@ -1652,4 +1660,303 @@ let x = y;
Однако мы создали глобальную переменную `y`, установив `y` равным `10`. Это значение доступно в любом месте нашего кода. `y` определен и содержит значение типа `"number"`. `console.log(typeof y)` возвращает `"number"`.
-
\ No newline at end of file
+
+
+---
+
+###### 55. Какой будет вывод?
+
+```javascript
+class Dog {
+ constructor(name) {
+ this.name = name;
+ }
+}
+
+Dog.prototype.bark = function() {
+ console.log(`Woof I am ${this.name}`);
+};
+
+const pet = new Dog("Mara");
+
+pet.bark();
+
+delete Dog.prototype.bark;
+
+pet.bark();
+```
+
+- A: `"Woof I am Mara"`, `TypeError`
+- B: `"Woof I am Mara"`,`"Woof I am Mara"`
+- C: `"Woof I am Mara"`, `undefined`
+- D: `TypeError`, `TypeError`
+
+Ответ
+
+
+#### Ответ: A
+
+Мы можем удалить свойства из объектов, используя ключевое слово `delete`, также в прототипе. Удаляя свойство в прототипе, оно больше не доступно в цепочке прототипов. В этом случае функция `bark` больше не доступна в прототипе после`delete Dog.prototype.bark`, но мы все еще пытаемся получить к ней доступ.
+
+Когда мы пытаемся вызвать что-то, что не является функцией, выдается `TypeError`. В этом случае `TypeError: pet.bark не является функцией`, поскольку` pet.bark` является `undefined`.
+
+
+
+
+---
+
+###### 56. Какой будет вывод?
+
+```javascript
+const set = new Set([1, 1, 2, 3, 4]);
+
+console.log(set);
+```
+
+- A: `[1, 1, 2, 3, 4]`
+- B: `[1, 2, 3, 4]`
+- C: `{1, 1, 2, 3, 4}`
+- D: `{1, 2, 3, 4}`
+
+Ответ
+
+
+#### Ответ: D
+
+Объект `Set` является коллекцией _unique_ значений: значение может появляться только один раз в наборе.
+
+Мы передали последовательность `[1, 1, 2, 3, 4]` с повторяющимся значением `1`. Поскольку в наборе не может быть двух одинаковых значений, одно из них удаляется. Это приводит к `{1, 2, 3, 4}`.
+
+
+
+
+---
+
+###### 57. Какой будет вывод?
+
+```javascript
+// counter.js
+let counter = 10;
+export default counter;
+```
+
+```javascript
+// index.js
+import myCounter from "./counter";
+
+myCounter += 1;
+
+console.log(myCounter);
+```
+
+- A: `10`
+- B: `11`
+- C: `Error`
+- D: `NaN`
+
+Ответ
+
+
+#### Ответ: C
+
+Импортированный модуль является _read-only_: вы не можете изменить импортированный модуль. Только модуль, который их экспортирует, может изменить его значение.
+
+Когда мы пытаемся увеличить значение `myCounter`, выдается ошибка: `myCounter` доступен только для чтения и не может быть изменен.
+
+
+
+
+---
+
+###### 58. Какой будет вывод?
+
+```javascript
+const name = "Lydia";
+age = 21;
+
+console.log(delete name);
+console.log(delete age);
+```
+
+- A: `false`, `true`
+- B: `"Lydia"`, `21`
+- C: `true`, `true`
+- D: `undefined`, `undefined`
+
+Ответ
+
+
+#### Ответ: A
+
+Оператор `delete` возвращает логическое значение: `true` при успешном удалении, иначе он вернет `false`. Однако переменные, объявленные с ключевым словом `var`,` const` или `let`, не могут быть удалены с помощью оператора` delete`.
+
+Переменная `name` была объявлена с ключевым словом `const`, поэтому ее удаление не было успешным: возвращается `false`. Когда мы устанавливаем `age` равным `21`, мы фактически добавляем свойство с именем `age` к глобальному объекту. Вы можете успешно удалить свойства из объектов, в том числе из глобального объекта, поэтому `delete age` возвращает `true`.
+
+
+
+
+---
+
+###### 59. Какой будет вывод?
+
+```javascript
+const numbers = [1, 2, 3, 4, 5];
+const [y] = numbers;
+
+console.log(y);
+```
+
+- A: `[[1, 2, 3, 4, 5]]`
+- B: `[1, 2, 3, 4, 5]`
+- C: `1`
+- D: `[1]`
+
+Ответ
+
+
+#### Ответ: C
+
+Мы можем распаковать значения из массивов или свойств из объектов путем деструктуризации. Например:
+
+```javascript
+[a, b] = [1, 2];
+```
+
+
+
+Значение `a` теперь равно `1`, а значение `b` теперь равно `2`. Что мы на самом деле сделали в этом вопросе, так это:
+
+```javascript
+[y] = [1, 2, 3, 4, 5];
+```
+
+
+
+Это означает, что значение `y` равно первому значению в массиве, которое является числом` 1`. Когда мы регистрируем `y`, возвращается `1`.
+
+
+
+
+---
+
+###### 60. Какой будет вывод?
+
+```javascript
+const user = { name: "Lydia", age: 21 };
+const admin = { admin: true, ...user };
+
+console.log(admin);
+```
+
+- A: `{ admin: true, user: { name: "Lydia", age: 21 } }`
+- B: `{ admin: true, name: "Lydia", age: 21 }`
+- C: `{ admin: true, user: ["Lydia", 21] }`
+- D: `{ admin: true }`
+
+Ответ
+
+
+#### Ответ: B
+
+Можно комбинировать объекты с помощью оператора распространения `...`. Это позволяет создавать копии пар ключ/значение одного объекта и добавлять их в другой объект. В этом случае мы создаем копии объекта `user` и добавляем их в объект `admin`. Объект `admin` теперь содержит скопированные пары ключ/значение, что приводит к `{admin: true, name: "Lydia", age: 21}`.
+
+
+
+
+---
+
+###### 61. Какой будет вывод?
+
+```javascript
+const person = { name: "Lydia" };
+
+Object.defineProperty(person, "age", { value: 21 });
+
+console.log(person);
+console.log(Object.keys(person));
+```
+
+- A: `{ name: "Lydia", age: 21 }`, `["name", "age"]`
+- B: `{ name: "Lydia", age: 21 }`, `["name"]`
+- C: `{ name: "Lydia"}`, `["name", "age"]`
+- D: `{ name: "Lydia"}`, `["age"]`
+
+Ответ
+
+
+#### Ответ: B
+
+С помощью метода `defineProperty` мы можем добавлять новые свойства к объекту или изменять существующие. Когда мы добавляем свойство к объекту с помощью метода `defineProperty`, они по умолчанию _не перечисляемые_. Метод `Object.keys` возвращает все имена _enumerable_ свойств объекта, в данном случае только `"name"`.
+
+Свойства, добавленные с помощью метода `defineProperty`, по умолчанию неизменны. Вы можете переопределить это поведение, используя свойства `writable`, `configurable` и `enumerable`. Таким образом, метод `defineProperty` дает вам гораздо больший контроль над свойствами, которые вы добавляете к объекту.
+
+
+
+
+---
+
+###### 62. Какой будет вывод?
+
+```javascript
+const settings = {
+ username: "lydiahallie",
+ level: 19,
+ health: 90
+};
+
+const data = JSON.stringify(settings, ["level", "health"]);
+console.log(data);
+```
+
+- A: `"{"level":19, "health":90}"`
+- B: `"{"username": "lydiahallie"}"`
+- C: `"["level", "health"]"`
+- D: `"{"username": "lydiahallie", "level":19, "health":90}"`
+
+Ответ
+
+
+#### Ответ: A
+
+Второй аргумент `JSON.stringify` - это _replacer_. Заменитель может быть либо функцией, либо массивом, и позволяет вам контролировать, что и как должны быть преобразованы в значения.
+
+Если заменитель является _array_, только свойства, имена которых включены в массив, будут добавлены в строку JSON. В этом случае включаются только свойства с именами `"level"` и `"health"`, `"username"` исключается. `data` теперь равен `"{"level":19, "health":90}"`.
+
+Если заменитель является _function_, эта функция вызывается для каждого свойства объекта, который вы преобразуете. Значение, возвращаемое из этой функции, будет значением свойства при добавлении в строку JSON. Если значение равно undefined, это свойство исключается из строки JSON.
+
+
+
+
+---
+
+###### 63. Какой будет вывод?
+
+```javascript
+let num = 10;
+
+const increaseNumber = () => num++;
+const increasePassedNumber = number => number++;
+
+const num1 = increaseNumber();
+const num2 = increasePassedNumber(num1);
+
+console.log(num1);
+console.log(num2);
+```
+
+- A: `10`, `10`
+- B: `10`, `11`
+- C: `11`, `11`
+- D: `11`, `12`
+
+Ответ
+
+
+#### Ответ: A
+
+Унарный оператор `++` _first возвращает_ значение операнда, _then приращивает_ значение операнда. Значение `num1` равно `10`, так как функция увеличений вначале возвращает значение `num`, которое равно `10`, и только затем увеличивает значение `num`.
+
+`num2` - это `10`, так как мы передали `num1` в `incpasePassedNumber`. `number` равно `10` (значение `num1`. Опять же, унарный оператор `++` _first возвращает_ значение операнда, _then увеличивает значение операнда. Значение `number` равно `10`, поэтому `num2` равно `10`.
+
+
+
From 4cd8bad730ed16681e93d9b1b21488746f8b0c1c Mon Sep 17 00:00:00 2001
From: Alexander Ivanov
Date: Wed, 3 Jul 2019 20:49:38 +0300
Subject: [PATCH 135/881] Translate line 10
---
README_ru-RU.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index b8f8ab31..9ef823ee 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -7,7 +7,7 @@
Ответы находятся в свернутой секции ниже вопросов. Просто нажми на "Ответ", чтобы развернуть. Удачи! :heart:
-List of available languages:
+Список доступных переводов:
* [English](./README.md)
* [中文版本](./README-zh_CN.md)
* [Versión en español](./README-ES.md)
From ff2c9bfb39b1add8865e014586bf8def11c12b23 Mon Sep 17 00:00:00 2001
From: Alexander Ivanov
Date: Wed, 3 Jul 2019 20:50:48 +0300
Subject: [PATCH 136/881] Typo
---
README_ru-RU.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_ru-RU.md b/README_ru-RU.md
index 9ef823ee..df536c26 100644
--- a/README_ru-RU.md
+++ b/README_ru-RU.md
@@ -20,7 +20,7 @@
* [Українська мова](./README-ua_UA.md)
* [Português Brasil](./README_pt_BR.md)
* [العربية](./README_AR.md)
-* [اللغة العامية - Egyptian Arabic](./README_ar-EG.md
+* [اللغة العامية - Egyptian Arabic](./README_ar-EG.md)
---
From 6587fe081f616cc1615596d43dc69c841a39c1b2 Mon Sep 17 00:00:00 2001
From: TuanTV
Date: Thu, 4 Jul 2019 18:29:12 +0700
Subject: [PATCH 137/881] add question to vietname and translate title
---
README-vi.md | 657 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 657 insertions(+)
diff --git a/README-vi.md b/README-vi.md
index 55e61bad..db91448a 100644
--- a/README-vi.md
+++ b/README-vi.md
@@ -1291,3 +1291,660 @@ String là một _iterable_. Thế nên _spread operator_ sẽ map toàn bộ c
+
+---
+
+###### 44. Ouput là gì?
+
+```javascript
+function* generator(i) {
+ yield i;
+ yield i * 2;
+}
+
+const gen = generator(10);
+
+console.log(gen.next().value);
+console.log(gen.next().value);
+```
+
+- A: `[0, 10], [10, 20]`
+- B: `20, 20`
+- C: `10, 20`
+- D: `0, 10 và 10, 20`
+
+Đáp án
+
+
+#### Đáp án: C
+
+Regular functions cannot be stopped mid-way after invocation. However, a generator function can be "stopped" midway, and later continue from where it stopped. Every time a generator function encounters a `yield` keyword, the function yields the value specified after it. Note that the generator function in that case doesn’t _return_ the value, it _yields_ the value.
+
+First, we initialize the generator function with `i` equal to `10`. We invoke the generator function using the `next()` method. The first time we invoke the generator function, `i` is equal to `10`. It encounters the first `yield` keyword: it yields the value of `i`. The generator is now "paused", and `10` gets logged.
+
+Then, we invoke the function again with the `next()` method. It starts to continue where it stopped previously, still with `i` equal to `10`. Now, it encounters the next `yield` keyword, and yields `i * 2`. `i` is equal to `10`, so it returns `10 * 2`, which is `20`. This results in `10, 20`.
+
+
+
+
+---
+
+###### 45. Giá trị trả về là gì?
+
+```javascript
+const firstPromise = new Promise((res, rej) => {
+ setTimeout(res, 500, "one");
+});
+
+const secondPromise = new Promise((res, rej) => {
+ setTimeout(res, 100, "two");
+});
+
+Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
+```
+
+- A: `"one"`
+- B: `"two"`
+- C: `"two" "one"`
+- D: `"one" "two"`
+
+Đáp án
+
+
+#### Đáp án: B
+
+When we pass multiple promises to the `Promise.race` method, it resolves/rejects the _first_ promise that resolves/rejects. To the `setTimeout` method, we pass a timer: 500ms for the first promise (`firstPromise`), and 100ms for the second promise (`secondPromise`). This means that the `secondPromise` resolves first with the value of `'two'`. `res` now holds the value of `'two'`, which gets logged.
+
+
+
+
+---
+
+###### 46. Ouput là gì?
+
+```javascript
+let person = { name: "Lydia" };
+const members = [person];
+person = null;
+
+console.log(members);
+```
+
+- A: `null`
+- B: `[null]`
+- C: `[{}]`
+- D: `[{ name: "Lydia" }]`
+
+Đáp án
+
+
+#### Đáp án: D
+
+First, we declare a variable `person` with the value of an object that has a `name` property.
+
+
+
+Then, we declare a variable called `members`. We set the first element of that array equal to the value of the `person` variable. Objects interact by _reference_ when setting them equal to each other. When you assign a reference from one variable to another, you make a _copy_ of that reference. (note that they don't have the _same_ reference!)
+
+
+
+Then, we set the variable `person` equal to `null`.
+
+
+
+We are only modifying the value of the `person` variable, and not the first element in the array, since that element has a different (copied) reference to the object. The first element in `members` still holds its reference to the original object. When we log the `members` array, the first element still holds the value of the object, which gets logged.
+
+
+
+
+---
+
+###### 47. Ouput là gì?
+
+```javascript
+const person = {
+ name: "Lydia",
+ age: 21
+};
+
+for (const item in person) {
+ console.log(item);
+}
+```
+
+- A: `{ name: "Lydia" }, { age: 21 }`
+- B: `"name", "age"`
+- C: `"Lydia", 21`
+- D: `["name", "Lydia"], ["age", 21]`
+
+Đáp án
+
+
+#### Đáp án: B
+
+With a `for-in` loop, we can iterate through object keys, in this case `name` and `age`. Under the hood, object keys are strings (if they're not a Symbol). On every loop, we set the value of `item`equal to the current key it’s iterating over. First, `item` is equal to `name`, and gets logged. Then, `item` is equal to `age`, which gets logged.
+
+
+
+
+---
+
+###### 48. Ouput là gì?
+
+```javascript
+console.log(3 + 4 + "5");
+```
+
+- A: `"345"`
+- B: `"75"`
+- C: `12`
+- D: `"12"`
+
+Đáp án
+
+
+#### Đáp án: B
+
+Operator associativity is the order in which the compiler evaluates the expressions, either left-to-right or right-to-left. This only happens if all operators have the _same_ precedence. We only have one type of operator: `+`. For addition, the associativity is left-to-right.
+
+`3 + 4` gets evaluated first. This results in the number `7`.
+
+`7 + '5'` results in `"75"` because of coercion. JavaScript converts the number `7` into a string, see question 15. We can concatenate two strings using the `+`operator. `"7" + "5"` results in `"75"`.
+
+
+
+
+---
+
+###### 49. What's the value of `num`?
+
+```javascript
+const num = parseInt("7*6", 10);
+```
+
+- A: `42`
+- B: `"42"`
+- C: `7`
+- D: `NaN`
+
+Đáp án
+
+
+#### Đáp án: C
+
+Only the first numbers in the string is returned. Based on the _radix_ (the second argument in order to specify what type of number we want to parse it to: base 10, hexadecimal, octal, binary, etc.), the `parseInt` checks whether the characters in the string are valid. Once it encounters a character that isn't a valid number in the radix, it stops parsing and ignores the following characters.
+
+`*` is not a valid number. It only parses `"7"` into the decimal `7`. `num` now holds the value of `7`.
+
+
+
+
+---
+
+###### 50. What's the output`?
+
+```javascript
+[1, 2, 3].map(num => {
+ if (typeof num === "number") return;
+ return num * 2;
+});
+```
+
+- A: `[]`
+- B: `[null, null, null]`
+- C: `[undefined, undefined, undefined]`
+- D: `[ 3 x empty ]`
+
+Đáp án
+
+
+#### Đáp án: C
+
+When mapping over the array, the value of `num` is equal to the element it’s currently looping over. In this case, the elements are numbers, so the condition of the if statement `typeof num === "number"` returns `true`. The map function creates a new array and inserts the values returned from the function.
+
+However, we don’t return a value. When we don’t return a value from the function, the function returns `undefined`. For every element in the array, the function block gets called, so for each element we return `undefined`.
+
+
+
+
+---
+
+###### 51. Ouput là gì?
+
+```javascript
+function getInfo(member, year) {
+ member.name = "Lydia";
+ year = "1998";
+}
+
+const person = { name: "Sarah" };
+const birthYear = "1997";
+
+getInfo(person, birthYear);
+
+console.log(person, birthYear);
+```
+
+- A: `{ name: "Lydia" }, "1997"`
+- B: `{ name: "Sarah" }, "1998"`
+- C: `{ name: "Lydia" }, "1998"`
+- D: `{ name: "Sarah" }, "1997"`
+
+Đáp án
+
+
+#### Đáp án: A
+
+Arguments are passed by _value_, unless their value is an object, then they're passed by _reference_. `birthYear` is passed by value, since it's a string, not an object. When we pass arguments by value, a _copy_ of that value is created (see question 46).
+
+The variable `birthYear` has a reference to the value `"1997"`. The argument `year` also has a reference to the value `"1997"`, but it's not the same value as `birthYear` has a reference to. When we update the value of `year` by setting `year` equal to `"1998"`, we are only updating the value of `year`. `birthYear` is still equal to `"1997"`.
+
+The value of `person` is an object. The argument `member` has a (copied) reference to the _same_ object. When we modify a property of the object `member` has a reference to, the value of `person` will also be modified, since they both have a reference to the same object. `person`'s `name` property is now equal to the value `"Lydia"`
+
+
+
+
+---
+
+###### 52. Ouput là gì?
+
+```javascript
+function greeting() {
+ throw "Hello world!";
+}
+
+function sayHi() {
+ try {
+ const data = greeting();
+ console.log("It worked!", data);
+ } catch (e) {
+ console.log("Oh no an error!", e);
+ }
+}
+
+sayHi();
+```
+
+- A: `"It worked! Hello world!"`
+- B: `"Oh no an error: undefined`
+- C: `SyntaxError: can only throw Error objects`
+- D: `"Oh no an error: Hello world!`
+
+Đáp án
+
+
+#### Đáp án: D
+
+With the `throw` statement, we can create custom errors. With this statement, you can throw exceptions. An exception can be a string, a number, a boolean or an object. In this case, our exception is the string `'Hello world'`.
+
+With the `catch` statement, we can specify what to do if an exception is thrown in the `try` block. An exception is thrown: the string `'Hello world'`. `e` is now equal to that string, which we log. This results in `'Oh an error: Hello world'`.
+
+
+
+
+---
+
+###### 53. Ouput là gì?
+
+```javascript
+function Car() {
+ this.make = "Lamborghini";
+ return { make: "Maserati" };
+}
+
+const myCar = new Car();
+console.log(myCar.make);
+```
+
+- A: `"Lamborghini"`
+- B: `"Maserati"`
+- C: `ReferenceError`
+- D: `TypeError`
+
+Đáp án
+
+
+#### Đáp án: B
+
+When you return a property, the value of the property is equal to the _returned_ value, not the value set in the constructor function. We return the string `"Maserati"`, so `myCar.make` is equal to `"Maserati"`.
+
+
+
+
+---
+
+###### 54. Ouput là gì?
+
+```javascript
+(() => {
+ let x = (y = 10);
+})();
+
+console.log(typeof x);
+console.log(typeof y);
+```
+
+- A: `"undefined", "number"`
+- B: `"number", "number"`
+- C: `"object", "number"`
+- D: `"number", "undefined"`
+
+Đáp án
+
+
+#### Đáp án: A
+
+`let x = y = 10;` is actually shorthand for:
+
+```javascript
+y = 10;
+let x = y;
+```
+
+When we set `y` equal to `10`, we actually add a property `y` to the global object (`window` in browser, `global` in Node). In a browser, `window.y` is now equal to `10`.
+
+Then, we declare a variable `x` with the value of `y`, which is `10`. Variables declared with the `let` keyword are _block scoped_, they are only defined within the block they're declared in; the immediately-invoked function (IIFE) in this case. When we use the `typeof` operator, the operand `x` is not defined: we are trying to access `x` outside of the block it's declared in. This means that `x` is not defined. Values who haven't been assigned a value or declared are of type `"undefined"`. `console.log(typeof x)` returns `"undefined"`.
+
+However, we created a global variable `y` when setting `y` equal to `10`. This value is accessible anywhere in our code. `y` is defined, and holds a value of type `"number"`. `console.log(typeof y)` returns `"number"`.
+
+
+
+
+---
+
+###### 55. Ouput là gì?
+
+```javascript
+class Dog {
+ constructor(name) {
+ this.name = name;
+ }
+}
+
+Dog.prototype.bark = function() {
+ console.log(`Woof I am ${this.name}`);
+};
+
+const pet = new Dog("Mara");
+
+pet.bark();
+
+delete Dog.prototype.bark;
+
+pet.bark();
+```
+
+- A: `"Woof I am Mara"`, `TypeError`
+- B: `"Woof I am Mara"`,`"Woof I am Mara"`
+- C: `"Woof I am Mara"`, `undefined`
+- D: `TypeError`, `TypeError`
+
+Đáp án
+
+
+#### Đáp án: A
+
+We can delete properties from objects using the `delete` keyword, also on the prototype. By deleting a property on the prototype, it is not available anymore in the prototype chain. In this case, the `bark` function is not available anymore on the prototype after `delete Dog.prototype.bark`, yet we still try to access it.
+
+When we try to invoke something that is not a function, a `TypeError` is thrown. In this case `TypeError: pet.bark is not a function`, since `pet.bark` is `undefined`.
+
+
+
+
+---
+
+###### 56. Ouput là gì?
+
+```javascript
+const set = new Set([1, 1, 2, 3, 4]);
+
+console.log(set);
+```
+
+- A: `[1, 1, 2, 3, 4]`
+- B: `[1, 2, 3, 4]`
+- C: `{1, 1, 2, 3, 4}`
+- D: `{1, 2, 3, 4}`
+
+Đáp án
+
+
+#### Đáp án: D
+
+The `Set` object is a collection of _unique_ values: a value can only occur once in a set.
+
+We passed the iterable `[1, 1, 2, 3, 4]` with a duplicate value `1`. Since we cannot have two of the same values in a set, one of them is removed. This results in `{1, 2, 3, 4}`.
+
+
+
+
+---
+
+###### 57. Ouput là gì?
+
+```javascript
+// counter.js
+let counter = 10;
+export default counter;
+```
+
+```javascript
+// index.js
+import myCounter from "./counter";
+
+myCounter += 1;
+
+console.log(myCounter);
+```
+
+- A: `10`
+- B: `11`
+- C: `Error`
+- D: `NaN`
+
+Đáp án
+
+
+#### Đáp án: C
+
+An imported module is _read-only_: you cannot modify the imported module. Only the module that exports them can change its value.
+
+When we try to increment the value of `myCounter`, it throws an error: `myCounter` is read-only and cannot be modified.
+
+
+
+
+---
+
+###### 58. Ouput là gì?
+
+```javascript
+const name = "Lydia";
+age = 21;
+
+console.log(delete name);
+console.log(delete age);
+```
+
+- A: `false`, `true`
+- B: `"Lydia"`, `21`
+- C: `true`, `true`
+- D: `undefined`, `undefined`
+
+Đáp án
+
+
+#### Đáp án: A
+
+The `delete` operator returns a boolean value: `true` on a successful deletion, else it'll return `false`. However, variables declared with the `var`, `const` or `let` keyword cannot be deleted using the `delete` operator.
+
+The `name` variable was declared with a `const` keyword, so its deletion is not successful: `false` is returned. When we set `age` equal to `21`, we actually added a property called `age` to the global object. You can successfully delete properties from objects this way, also the global object, so `delete age` returns `true`.
+
+
+
+
+---
+
+###### 59. Ouput là gì?
+
+```javascript
+const numbers = [1, 2, 3, 4, 5];
+const [y] = numbers;
+
+console.log(y);
+```
+
+- A: `[[1, 2, 3, 4, 5]]`
+- B: `[1, 2, 3, 4, 5]`
+- C: `1`
+- D: `[1]`
+
+Đáp án
+
+
+#### Đáp án: C
+
+We can unpack values from arrays or properties from objects through destructuring. For example:
+
+```javascript
+[a, b] = [1, 2];
+```
+
+
+
+The value of `a` is now `1`, and the value of `b` is now `2`. What we actually did in the question, is:
+
+```javascript
+[y] = [1, 2, 3, 4, 5];
+```
+
+
+
+This means that the value of `y` is equal to the first value in the array, which is the number `1`. When we log `y`, `1` is returned.
+
+
+
+
+---
+
+###### 60. Ouput là gì?
+
+```javascript
+const user = { name: "Lydia", age: 21 };
+const admin = { admin: true, ...user };
+
+console.log(admin);
+```
+
+- A: `{ admin: true, user: { name: "Lydia", age: 21 } }`
+- B: `{ admin: true, name: "Lydia", age: 21 }`
+- C: `{ admin: true, user: ["Lydia", 21] }`
+- D: `{ admin: true }`
+
+Đáp án
+
+
+#### Đáp án: B
+
+It's possible to combine objects using the spread operator `...`. It lets you create copies of the key/value pairs of one object, and add them to another object. In this case, we create copies of the `user` object, and add them to the `admin` object. The `admin` object now contains the copied key/value pairs, which results in `{ admin: true, name: "Lydia", age: 21 }`.
+
+
+
+
+---
+
+###### 61. Ouput là gì?
+
+```javascript
+const person = { name: "Lydia" };
+
+Object.defineProperty(person, "age", { value: 21 });
+
+console.log(person);
+console.log(Object.keys(person));
+```
+
+- A: `{ name: "Lydia", age: 21 }`, `["name", "age"]`
+- B: `{ name: "Lydia", age: 21 }`, `["name"]`
+- C: `{ name: "Lydia"}`, `["name", "age"]`
+- D: `{ name: "Lydia"}`, `["age"]`
+
+Đáp án
+
+
+#### Đáp án: B
+
+With the `defineProperty` method, we can add new properties to an object, or modify existing ones. When we add a property to an object using the `defineProperty` method, they are by default _not enumerable_. The `Object.keys` method returns all _enumerable_ property names from an object, in this case only `"name"`.
+
+Properties added using the `defineProperty` method are immutable by default. You can override this behavior using the `writable`, `configurable` and `enumerable` properties. This way, the `defineProperty` method gives you a lot more control over the properties you're adding to an object.
+
+
+
+
+---
+
+###### 62. Ouput là gì?
+
+```javascript
+const settings = {
+ username: "lydiahallie",
+ level: 19,
+ health: 90
+};
+
+const data = JSON.stringify(settings, ["level", "health"]);
+console.log(data);
+```
+
+- A: `"{"level":19, "health":90}"`
+- B: `"{"username": "lydiahallie"}"`
+- C: `"["level", "health"]"`
+- D: `"{"username": "lydiahallie", "level":19, "health":90}"`
+
+Đáp án
+
+
+#### Đáp án: A
+
+The second argument of `JSON.stringify` is the _replacer_. The replacer can either be a function or an array, and lets you control what and how the values should be stringified.
+
+If the replacer is an _array_, only the properties which names are included in the array will be added to the JSON string. In this case, only the properies with the names `"level"` and `"health"` are included, `"username"` is excluded. `data` is now equal to `"{"level":19, "health":90}"`.
+
+If the replacer is a _function_, this function gets called on every property in the object you're stringifying. The value returned from this function will be the value of the property when it's added to the JSON string. If the value is `undefined`, this property is excluded from the JSON string.
+
+
+
+
+---
+
+###### 63. Ouput là gì?
+
+```javascript
+let num = 10;
+
+const increaseNumber = () => num++;
+const increasePassedNumber = number => number++;
+
+const num1 = increaseNumber();
+const num2 = increasePassedNumber(num1);
+
+console.log(num1);
+console.log(num2);
+```
+
+- A: `10`, `10`
+- B: `10`, `11`
+- C: `11`, `11`
+- D: `11`, `12`
+
+Đáp án
+
+
+#### Đáp án: A
+
+The unary operator `++` _first returns_ the value of the operand, _then increments_ the value of the operand. The value of `num1` is `10`, since the `increaseNumber` function first returns the value of `num`, which is `10`, and only increments the value of `num` afterwards.
+
+`num2` is `10`, since we passed `num1` to the `increasePassedNumber`. `number` is equal to `10`(the value of `num1`. Again, the unary operator `++` _first returns_ the value of the operand, _then increments_ the value of the operand. The value of `number` is `10`, so `num2` is equal to `10`.
+
+
+
\ No newline at end of file
From 8b2bea76c2ded8e0ae25edb9dd5d7f8013c5792b Mon Sep 17 00:00:00 2001
From: TuanTV
Date: Thu, 4 Jul 2019 18:32:25 +0700
Subject: [PATCH 138/881] add list language other
---
README-vi.md | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/README-vi.md b/README-vi.md
index db91448a..bcb536b5 100644
--- a/README-vi.md
+++ b/README-vi.md
@@ -6,8 +6,20 @@ Các câu hỏi sẽ từ cơ bản đến nâng cao: kiểm tra trình độ Ja
Các đáp án được đặt dưới mỗi câu hỏi, hãy click để tham khảo chúng. Chúc may mắn :heart:
-[English Version](./README.md)
-[Українська мова](./README-ua_UA.md)
+Danh sách các ngôn ngữ khác:
+* [English](./README.md)
+* [中文版本](./README-zh_CN.md)
+* [Versión en español](./README-ES.md)
+* [日本語](./README-ja_JA.md)
+* [한국어](./README-ko_KR.md)
+* [Русский](./README_ru-RU.md)
+* [Western Balkan](./README-bs_BS.md)
+* [Deutsch](./README-de_DE.md)
+* [Tiếng Việt](./README-vi.md)
+* [Українська мова](./README-ua_UA.md)
+* [Português Brasil](./README_pt_BR.md)
+* [العربية](./README_AR.md)
+* [اللغة العامية - Egyptian Arabic](./README_ar-EG.md)
---
From 7265ebaaafee394aa68d1bad3299bd3794476106 Mon Sep 17 00:00:00 2001
From: Alexander Ivanov
Date: Thu, 4 Jul 2019 14:45:53 +0300
Subject: [PATCH 139/881] Fix #139
---
README-zh_CN.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README-zh_CN.md b/README-zh_CN.md
index 21740dc3..92e68124 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -110,7 +110,7 @@ shape.perimeter()
###### 4. 输出是什么?
```javascript
-;+true
++true
!'Lydia'
```
From 859f7839cc91e0b1ffcf732a7e4ddaac77fde31c Mon Sep 17 00:00:00 2001
From: Alexander Ivanov
Date: Thu, 4 Jul 2019 15:03:57 +0300
Subject: [PATCH 140/881] Add as all
Signed-off-by: Alexander Ivanov
---
README-zh_CN.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README-zh_CN.md b/README-zh_CN.md
index 92e68124..23ae293b 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -110,8 +110,8 @@ shape.perimeter()
###### 4. 输出是什么?
```javascript
-+true
-!'Lydia'
++true;
+!"Lydia";
```
- A: `1` and `false`
From 986220b745f1cf0fe8177a3875abf8cff4b719c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B5=E4=B9=8B=E7=90=9B?=
Date: Thu, 4 Jul 2019 20:19:20 +0800
Subject: [PATCH 141/881] translate 44-63 to ZH_CN
---
README-zh_CN.md | 659 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 659 insertions(+)
diff --git a/README-zh_CN.md b/README-zh_CN.md
index 21740dc3..64d8e03a 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -1286,3 +1286,662 @@ string 类型是可迭代的。扩展运算符将迭代的每个字符映射成
+
+---
+
+###### 44. 输出是什么?
+
+```javascript
+function* generator(i) {
+ yield i;
+ yield i * 2;
+}
+
+const gen = generator(10);
+
+console.log(gen.next().value);
+console.log(gen.next().value);
+```
+
+- A: `[0, 10], [10, 20]`
+- B: `20, 20`
+- C: `10, 20`
+- D: `0, 10 and 10, 20`
+
+答案
+
+
+#### 答案: C
+
+一般的函数在执行之后是不能中途停下的。但是,生成器函数却可以中途“停下”,之后可以再从停下的地方继续。当生成器遇到`yield`关键字的时候,会生成`yield`后面的值。注意,生成器在这种情况下不 _返回_ (_return_ )值,而是 _生成_ (_yield_)值。
+
+首先,我们用`10`作为参数`i`来初始化生成器函数。然后使用`next()`方法一步步执行生成器。第一次执行生成器的时候,`i`的值为`10`,遇到第一个`yield`关键字,它要生成`i`的值。此时,生成器“暂停”,生成了`10`。
+
+然后,我们再执行`next()`方法。生成器会从刚才暂停的地方继续,这个时候`i`还是`10`。于是我们走到了第二个`yield`关键字处,这时候需要生成的值是`i*2`,`i`为`10`,那么此时生成的值便是`20`。所以这道题的最终结果是`10,20`。
+
+
+
+
+
+###### 45. 返回值是什么?
+
+```javascript
+const firstPromise = new Promise((res, rej) => {
+ setTimeout(res, 500, "one");
+});
+
+const secondPromise = new Promise((res, rej) => {
+ setTimeout(res, 100, "two");
+});
+
+Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
+```
+
+- A: `"one"`
+- B: `"two"`
+- C: `"two" "one"`
+- D: `"one" "two"`
+
+答案
+
+
+#### 答案: B
+
+当我们向`Promise.race`方法中传入多个`Promise`时,会进行 _优先_ 解析。在这个例子中,我们用`setTimeout`给`firstPromise`和`secondPromise`分别设定了500ms和100ms的定时器。这意味着`secondPromise`会首先解析出字符串`two`。那么此时`res`参数即为`two`,是为输出结果。
+
+
+
+
+
+---
+
+###### 46. 输出是什么?
+
+```javascript
+let person = { name: "Lydia" };
+const members = [person];
+person = null;
+
+console.log(members);
+```
+
+- A: `null`
+- B: `[null]`
+- C: `[{}]`
+- D: `[{ name: "Lydia" }]`
+
+答案
+
+
+#### 答案: D
+
+
+首先我们声明了一个拥有`name`属性的对象 `person`。
+
+
+
+然后我们又声明了一个变量`members`. 将首个元素赋值为变量`person`。 当设置两个对象彼此相等时,它们会通过 _引用_ 进行交互。但是当你将引用从一个变量分配至另一个变量时,其实只是执行了一个 _复制_ 操作。(注意一点,他们的引用 _并不相同_!)
+
+
+
+接下来我们让`person`等于`null`。
+
+
+
+我们没有修改数组第一个元素的值,而只是修改了变量`person`的值,因为元素(复制而来)的引用与`person`不同。`members`的第一个元素仍然保持着对原始对象的引用。当我们输出`members`数组时,第一个元素会将引用的对象打印出来。
+
+
+
+
+---
+
+###### 47. 输出是什么?
+
+```javascript
+const person = {
+ name: "Lydia",
+ age: 21
+};
+
+for (const item in person) {
+ console.log(item);
+}
+```
+
+- A: `{ name: "Lydia" }, { age: 21 }`
+- B: `"name", "age"`
+- C: `"Lydia", 21`
+- D: `["name", "Lydia"], ["age", 21]`
+
+答案
+
+
+#### 答案: B
+
+在`for-in`循环中,我们可以通过对象的key来进行迭代,也就是这里的`name`和`age`。在底层,对象的key都是字符串(如果他们不是Symbol的话)。在每次循环中,我们将`item`设定为当前遍历到的key.所以一开始,`item`是`name`,之后 `item`输出的则是`age`。
+
+
+
+
+---
+
+###### 48. 输出是什么?
+
+```javascript
+console.log(3 + 4 + "5");
+```
+
+- A: `"345"`
+- B: `"75"`
+- C: `12`
+- D: `"12"`
+
+答案
+
+
+#### 答案: B
+
+当所有运算符的 _优先级_ 相同时,计算表达式需要确定运算符的结合顺序,即从右到左还是从左往右。在这个例子中,我们只有一类运算符`+`,对于加法来说,结合顺序就死从左到右。
+
+`3 + 4`首先计算,得到数字`7`.
+
+由于类型的强制转换,`7 + '5'`的结果是`"75"`. JavaScript将`7`转换成了字符串,可以参考问题15.我们可以用`+`号把两个字符串连接起来。 `"7" + "5"` 就得到了`"75"`.
+
+
+
+
+---
+
+###### 49. `num`的值是什么?
+
+```javascript
+const num = parseInt("7*6", 10);
+```
+
+- A: `42`
+- B: `"42"`
+- C: `7`
+- D: `NaN`
+
+答案
+
+
+#### 答案: C
+
+只返回了字符串中第一个字母. 设定了 _进制_ 后 (也就是第二个参数,指定需要解析的数字是什么进制: 十进制、十六机制、八进制、二进制等等……),`parseInt` 检查字符串中的字符是否合法. 一旦遇到一个在指定进制中不合法的字符后,立即停止解析并且忽略后面所有的字符。
+
+`*`就是不合法的数字字符。所以只解析到`"7"`,并将其解析为十进制的`7`. `num`的值即为`7`.
+
+
+
+
+---
+
+###### 50. 输出是什么?
+
+```javascript
+[1, 2, 3].map(num => {
+ if (typeof num === "number") return;
+ return num * 2;
+});
+```
+
+- A: `[]`
+- B: `[null, null, null]`
+- C: `[undefined, undefined, undefined]`
+- D: `[ 3 x empty ]`
+
+答案
+
+
+#### 答案: C
+
+对数组进行映射的时候,`num`就是当前循环到的元素. 在这个例子中,所有的映射都是number类型,所以if中的判断`typeof num === "number"`结果都是`true`.map函数创建了新数组并且将函数的返回值插入数组。
+
+但是,没有任何值返回。当函数没有返回任何值时,即默认返回`undefined`.对数组中的每一个元素来说,函数块都得到了这个返回值,所以结果中每一个元素都是`undefined`.
+
+
+
+
+---
+
+###### 51. 输出的是什么?
+
+```javascript
+function getInfo(member, year) {
+ member.name = "Lydia";
+ year = "1998";
+}
+
+const person = { name: "Sarah" };
+const birthYear = "1997";
+
+getInfo(person, birthYear);
+
+console.log(person, birthYear);
+```
+
+- A: `{ name: "Lydia" }, "1997"`
+- B: `{ name: "Sarah" }, "1998"`
+- C: `{ name: "Lydia" }, "1998"`
+- D: `{ name: "Sarah" }, "1997"`
+
+答案
+
+
+#### 答案: A
+
+普通参数都是 _值_ 传递的,而对象则不同,是 _引用_ 传递。所以说,`birthYear`是值传递,因为他是个字符串而不是对象。当我们对参数进行值传递时,会创建一份该值的 _复制_ 。(可以参考问题46)
+
+变量`birthYear`有一个对`"1997"`的引用,而传入的参数也有一个对`"1997"`的引用,但二者的引用并不相同。当我们通过给 `year`赋值`"1998"`来更新`year`的值的时候我们只是更新了`year`(的引用)。此时`birthYear`仍然是`"1997"`.
+
+而`person`是个对象。参数`member`引用与之 _相同的_ 对象。当我们修改`member`所引用对象的属性时,`person`的相应属性也被修改了,因为他们引用了相同的对象. `person`的 `name`属性也变成了 `"Lydia"`.
+
+
+
+
+---
+
+###### 52. 输出是什么?
+
+```javascript
+function greeting() {
+ throw "Hello world!";
+}
+
+function sayHi() {
+ try {
+ const data = greeting();
+ console.log("It worked!", data);
+ } catch (e) {
+ console.log("Oh no an error!", e);
+ }
+}
+
+sayHi();
+```
+
+- A: `"It worked! Hello world!"`
+- B: `"Oh no an error: undefined`
+- C: `SyntaxError: can only throw Error objects`
+- D: `"Oh no an error: Hello world!`
+
+答案
+
+
+#### 答案: D
+
+通过`throw`语句,我么可以创建自定义错误。 而通过它,我们可以抛出异常。异常可以是一个字符串, 一个 数字, 一个 布尔类型 或者是一个 对象。在本例中,我们的异常是字符串`'Hello world'`.
+
+通过 `catch`语句,我们可以设定当`try`语句块中抛出异常后应该做什么处理。在本例中抛出的异常是字符串`'Hello world'`. `e`就是这个字符串,因此被输出。最终结果就是`'Oh an error: Hello world'`.
+
+
+
+
+---
+
+###### 53. 输出是什么?
+
+```javascript
+function Car() {
+ this.make = "Lamborghini";
+ return { make: "Maserati" };
+}
+
+const myCar = new Car();
+console.log(myCar.make);
+```
+
+- A: `"Lamborghini"`
+- B: `"Maserati"`
+- C: `ReferenceError`
+- D: `TypeError`
+
+答案
+
+
+#### 答案: B
+
+返回属性的时候,属性的值等于 _返回的_ 值,而不是构造函数中设定的值。我们返回了字符串 `"Maserati"`,所以 `myCar.make`等于`"Maserati"`.
+
+
+
+
+---
+
+###### 54. 输出是什么?
+
+```javascript
+(() => {
+ let x = (y = 10);
+})();
+
+console.log(typeof x);
+console.log(typeof y);
+```
+
+- A: `"undefined", "number"`
+- B: `"number", "number"`
+- C: `"object", "number"`
+- D: `"number", "undefined"`
+
+答案
+
+
+#### 答案: A
+
+`let x = y = 10;` 是下面这个表达式的缩写:
+
+```javascript
+y = 10;
+let x = y;
+```
+
+我们设定`y`等于`10`时,我们实际上增加了一个属性`y`给全局对象(浏览器里的`window`, Nodejs里的`global`)。在浏览器中, `window.y`等于`10`.
+
+然后我们声明了变量`x`等于`y`,也是`10`.但变量是使用 `let`声明的,它只作用于 _块级作用域_, 仅在声明它的块中有效;就是案例中的立即调用表达式(IIFE)。使用`typeof`操作符时, 操作值 `x`没有被定义:因为我们在`x`声明块的外部,无法调用它。这就意味着`x`未定义。未分配或是未声明的变量类型为`"undefined"`. `console.log(typeof x)`返回`"undefined"`.
+
+而我们创建了全局变量`y`,并且设定`y`等于`10`.这个值在我们的代码各处都访问的到。 `y`已经被定义了,而且有一个`"number"`类型的值。 `console.log(typeof y)`返回`"number"`.
+
+
+
+
+---
+
+###### 55. 输出是什么?
+
+```javascript
+class Dog {
+ constructor(name) {
+ this.name = name;
+ }
+}
+
+Dog.prototype.bark = function() {
+ console.log(`Woof I am ${this.name}`);
+};
+
+const pet = new Dog("Mara");
+
+pet.bark();
+
+delete Dog.prototype.bark;
+
+pet.bark();
+```
+
+- A: `"Woof I am Mara"`, `TypeError`
+- B: `"Woof I am Mara"`,`"Woof I am Mara"`
+- C: `"Woof I am Mara"`, `undefined`
+- D: `TypeError`, `TypeError`
+
+答案
+
+
+#### 答案: A
+
+我们可以用`delete`关键字删除对象的属性,对原型也是适用的。删除了原型的属性后,该属性在原型链上就不可用了。在本例中,函数`bark`在执行了`delete Dog.prototype.bark`后不可用, 然而后面的代码还在调用它。
+
+当我们尝试调用一个不存在的函数时`TypeError`异常会被抛出。在本例中就是 `TypeError: pet.bark is not a function`,因为`pet.bark`是`undefined`.
+
+
+
+
+---
+
+###### 56. 输出是什么?
+
+```javascript
+const set = new Set([1, 1, 2, 3, 4]);
+
+console.log(set);
+```
+
+- A: `[1, 1, 2, 3, 4]`
+- B: `[1, 2, 3, 4]`
+- C: `{1, 1, 2, 3, 4}`
+- D: `{1, 2, 3, 4}`
+
+答案
+
+
+#### 答案: D
+
+`Set`对象手机 _独一无二_ 的值:也就是说同一个值在其中仅出现一次。
+
+我们传入了数组`[1, 1, 2, 3, 4]`,他有一个重复值`1`.以为一个集合里不能有两个重复的值,其中一个就被移除了。所以结果是 `{1, 2, 3, 4}`.
+
+
+
+
+---
+
+###### 57. 输出是什么?
+
+```javascript
+// counter.js
+let counter = 10;
+export default counter;
+```
+
+```javascript
+// index.js
+import myCounter from "./counter";
+
+myCounter += 1;
+
+console.log(myCounter);
+```
+
+- A: `10`
+- B: `11`
+- C: `Error`
+- D: `NaN`
+
+答案
+
+
+#### 答案: C
+
+引入的模块是 _只读_ 的: 你不能修改引入的模块。只有导出他们的模块才能修改其值。
+
+当我们给`myCounter`增加一个值的时候会抛出一个异常: `myCounter`是只读的,不能被修改。
+
+
+
+
+---
+
+###### 58. 输出是什么?
+
+```javascript
+const name = "Lydia";
+age = 21;
+
+console.log(delete name);
+console.log(delete age);
+```
+
+- A: `false`, `true`
+- B: `"Lydia"`, `21`
+- C: `true`, `true`
+- D: `undefined`, `undefined`
+
+答案
+
+
+#### 答案: A
+
+`delete`操作符返回一个布尔值: `true`指删除成功,否则返回`false`. 但是通过 `var`, `const` 或 `let` 关键字声明的变量无法用 `delete` 操作符来删除。
+
+`name`变量由`const`关键字声明,所以删除不成功:返回 `false`. 而我们设定`age`等于`21`时,我们实际上添加了一个名为`age`的属性给全局对象。对象中的属性是可以删除的,全局对象也是如此,所以`delete age`返回`true`.
+
+
+
+
+---
+
+###### 59. 输出是什么?
+
+```javascript
+const numbers = [1, 2, 3, 4, 5];
+const [y] = numbers;
+
+console.log(y);
+```
+
+- A: `[[1, 2, 3, 4, 5]]`
+- B: `[1, 2, 3, 4, 5]`
+- C: `1`
+- D: `[1]`
+
+答案
+
+
+#### 答案: C
+
+我们可以通过解构赋值来解析来自对象的数组或属性的值,比如说:
+
+```javascript
+[a, b] = [1, 2];
+```
+
+
+
+`a`的值现在是`1`,`b`的值现在是`2`.而在题目中,我们是这么做的:
+
+```javascript
+[y] = [1, 2, 3, 4, 5];
+```
+
+
+
+也就是说,`y`等于数组的第一个值就是数字`1`.我们输出`y`, 返回`1`.
+
+
+
+
+---
+
+###### 60. 输出是什么?
+
+```javascript
+const user = { name: "Lydia", age: 21 };
+const admin = { admin: true, ...user };
+
+console.log(admin);
+```
+
+- A: `{ admin: true, user: { name: "Lydia", age: 21 } }`
+- B: `{ admin: true, name: "Lydia", age: 21 }`
+- C: `{ admin: true, user: ["Lydia", 21] }`
+- D: `{ admin: true }`
+
+答案
+
+
+#### 答案: B
+
+扩展运算符`...`为对象的组合提供了可能。你可以复制对象中的键值对,然后把它们加到另一个对象里去。在本例中,我们复制了`user`对象键值对,然后把它们加入到`admin`对象中。`admin`对象就拥有了这些键值对,所以结果为`{ admin: true, name: "Lydia", age: 21 }`.
+
+
+
+
+---
+
+###### 61. 输出是什么?
+
+```javascript
+const person = { name: "Lydia" };
+
+Object.defineProperty(person, "age", { value: 21 });
+
+console.log(person);
+console.log(Object.keys(person));
+```
+
+- A: `{ name: "Lydia", age: 21 }`, `["name", "age"]`
+- B: `{ name: "Lydia", age: 21 }`, `["name"]`
+- C: `{ name: "Lydia"}`, `["name", "age"]`
+- D: `{ name: "Lydia"}`, `["age"]`
+
+答案
+
+
+#### 答案: B
+
+通过`defineProperty`方法,我们可以给对象添加一个新属性,或者修改已经存在的属性。而我们使用`defineProperty`方法给对象添加了一个属性之后,属性默认为 _不可枚举(not enumerable)_. `Object.keys`方法仅返回对象中 _可枚举(enumerable)_ 的属性,因此只剩下了`"name"`.
+
+用`defineProperty`方法添加的属性默认不可变。你可以通过`writable`, `configurable` 和 `enumerable`属性来改变这一行为。这样的话, 相比于自己添加的属性,`defineProperty`方法添加的属性有了更多的控制权。
+
+
+
+
+---
+
+###### 62. 输出是什么?
+
+```javascript
+const settings = {
+ username: "lydiahallie",
+ level: 19,
+ health: 90
+};
+
+const data = JSON.stringify(settings, ["level", "health"]);
+console.log(data);
+```
+
+- A: `"{"level":19, "health":90}"`
+- B: `"{"username": "lydiahallie"}"`
+- C: `"["level", "health"]"`
+- D: `"{"username": "lydiahallie", "level":19, "health":90}"`
+
+答案
+
+
+#### 答案: A
+
+`JSON.stringify`的第二个参数是 _替代者(replacer)_. 替代者(replacer)可以是个函数或数组,用以控制哪些值如何被转换为字符串。
+
+如果替代者(replacer)是个 _数组_ ,那么就只有包含在数组中的属性将会被转化为字符串。在本例中,只有名为`"level"` 和 `"health"` 的属性被包括进来, `"username"`则被排除在外。 `data` 就等于 `"{"level":19, "health":90}"`.
+
+而如果替代者(replacer)是个 _函数_,这个函数将被对象的每个属性都调用一遍。
+函数返回的值会成为这个属性的值,最终体现在转化后的JSON字符串中(译者注:Chrome下,经过实验,如果所有属性均返回同一个值的时候有异常,会直接将返回值作为结果输出而不会输出JSON字符串),而如果返回值为`undefined`,则该属性会被排除在外。
+
+
+
+
+---
+
+###### 63. 输出是什么?
+
+```javascript
+let num = 10;
+
+const increaseNumber = () => num++;
+const increasePassedNumber = number => number++;
+
+const num1 = increaseNumber();
+const num2 = increasePassedNumber(num1);
+
+console.log(num1);
+console.log(num2);
+```
+
+- A: `10`, `10`
+- B: `10`, `11`
+- C: `11`, `11`
+- D: `11`, `12`
+
+答案
+
+
+#### 答案: A
+
+一元操作符 `++` _先返回_ 操作值, _再累加_ 操作值。`num1`的值是`10`, 因为`increaseNumber`函数首先返回`num`的值,也就是`10`,随后再进行 `num`的累加。
+
+`num2`是`10`因为我们将 `num1`传入`increasePassedNumber`. `number`等于`10`(`num1`的值。同样道理,`++` _先返回_ 操作值, _再累加_ 操作值。) `number`是`10`,所以`num2`也是`10`.
+
+
+
From 51c56ec1ed64e0b3d01820a484bd326fe73c76d6 Mon Sep 17 00:00:00 2001
From: Reg
Date: Thu, 4 Jul 2019 23:35:21 +0800
Subject: [PATCH 142/881] fix: Remove the extra symbols
On question 35, 38, 40.
---
README-zh_CN.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/README-zh_CN.md b/README-zh_CN.md
index 08aa81ea..d1db96f4 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -1040,8 +1040,8 @@ typeof sayHi()
```javascript
0
new Number(0)
-;('')
-;(' ')
+('')
+(' ')
new Boolean(false)
undefined
```
@@ -1130,12 +1130,12 @@ console.log(numbers)
###### 38. 输出是什么?
```javascript
-;(() => {
+(() => {
let x, y
try {
throw new Error()
} catch (x) {
- ;(x = 1), (y = 2)
+ (x = 1), (y = 2)
console.log(x)
}
console.log(x)
@@ -1188,7 +1188,7 @@ JavaScript 只有基本类型和对象。
###### 40. 输出是什么?
```javascript
-;[[0, 1], [2, 3]].reduce(
+[[0, 1], [2, 3]].reduce(
(acc, cur) => {
return acc.concat(cur)
},
From d89414e0611d6baafadf582e82b052e64c472cdc Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:28:43 +0200
Subject: [PATCH 143/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index a8dfb5c1..a4e35ba6 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -66,7 +66,7 @@ for (let i = 0; i < 3; i++) {
#### Réponse: C
-À cause du système de queue dans JavaScript, la fonction de rappel _(callback)_ du `setTimeout` est appellée _après_ que la boucle soit exécutée. Comme la variable `i` dans la première boucle est déclarée avec le mot clé `var`, c'est une variable global. Pendant la boucle, nous incrémentons la valeur de `i` par `1` à chaque fois, en utilisant l'opérateur arithmétique `++`. Lorsque la fonction de rappel _(callback)_ du `setTimeout` est invoquée, `i` est égal à `3` dans le premier exemple.
+À cause du système de queue dans JavaScript, la fonction de rappel _(callback)_ du `setTimeout` est appelée _après_ que la boucle soit exécutée. Comme la variable `i` dans la première boucle est déclarée avec le mot-clé `var`, c'est une variable globale. Pendant la boucle, nous incrémentons la valeur de `i` de `1` à chaque fois, en utilisant l'opérateur arithmétique `++`. Lorsque la fonction de rappel _(callback)_ du `setTimeout` est invoquée, `i` est égal à `3` dans le premier exemple.
Dans la seconde boucle, la variable `i` est déclarée avec le mot clé `let` : les variables déclarées avec `let` (et `const`) ont une portée de bloc (tout ce qui est entre `{ }` est considéré comme un bloc). Pendant chaque itération, `i` aura une nouvelle valeur, et chaque valeur sera définie dans la boucle.
From aad533d236665fa553cb5997987d4b6bf8ed28ea Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:29:04 +0200
Subject: [PATCH 144/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index a4e35ba6..26ecbe25 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -100,7 +100,7 @@ shape.perimeter();
#### Réponse: B
-Notez que le valeur de `diameter` est une fonction régulière, alors que `perimeter` est une fonction fléchée.
+Notez que la valeur de `diameter` est une fonction régulière, alors que celle de `perimeter` est une fonction fléchée.
Avec les fonctions fléchée, le mot clé `this` réfère à son périmètre actuel, contrairement au fonctions régulières ! Cela signifie que lorsque nous appelons `perimeter`, elle ne réfère pas à l'objet shape, mais à son périmètre actuel (`window` par exemple).
From cfe69467ae6d3c0f60511fc2342aef578ca54fde Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:29:55 +0200
Subject: [PATCH 145/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 26ecbe25..69c1cc39 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -129,7 +129,7 @@ Il n'y a pas de valeur `radius` dans cet objet, on retournera `undefined`.
L'opérateur arithmétique `+` essait de convertir un opérande en une valeur numérique. `true` devient `1`, et `false` devient `0`.
-La chaine de caractère `'Lydia'` est une value considérée comme vraie _(truthy)_. Ce que nous sommes actuellement entrain de demander, c'est "est-ce que cette valeur vraie est fausse ?". Ce qui retournera `false`.
+La chaine de caractère `'Lydia'` est une valeur considérée comme vraie _(truthy)_. Ce que nous sommes actuellement en train de demander, c'est "est-ce que cette valeur considérée comme vraie est fausse ?". Ce qui retournera `false`.
From 6247050d14f2f6410b9ab7042fe666fa5e621743 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:30:14 +0200
Subject: [PATCH 146/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 69c1cc39..f4ba3960 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -159,7 +159,7 @@ const mouse = {
#### Réponse: A
-En JavaScript, toutes les clé d'objet sont des chaines de caractères (sauf si c'est un Symbol). Bien que nous ne puission pas les _typer_ comme des chaines de caractères, elles sont converties en chaines de caractères sous le capot.
+En JavaScript, toutes les clés d'objet sont des chaines de caractères (sauf si c'est un Symbol). Bien que nous ne puissions pas les _typer_ comme des chaines de caractères, elles sont converties en chaines de caractères sous le capot.
JavaScript interprète (ou décompresse) les instructions. Lorsque nous utilisons la notation pas crochet, il voit le premier crochet `[` et continue jusqu'à ce qu'il trouve le crochet fermant `]`. Seulement après, il évalue l'instruction.
From 8e155e32f43c3c9a5b83bc35091c190ea76dc2e1 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:30:37 +0200
Subject: [PATCH 147/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index f4ba3960..9edbd53a 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -196,7 +196,7 @@ console.log(d.greeting);
#### Réponse: A
-En JavaScript, tous les object intéragisent par _référence_ en plaçant égaux les uns aux autres.
+En JavaScript, tous les objets interagissent par _référence_ lorsqu'on les définit égaux les uns aux autres.
Premièrement, la variable `c` contaient une valeur d'objet. Plus tard, nous assignons `d` avec la même réference que `c` à l'objet.
From 94fd29d1f1f610cce08c7c4a1f5a3c09424b4aaa Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:30:50 +0200
Subject: [PATCH 148/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 9edbd53a..29b0fb4d 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -570,7 +570,7 @@ Lorsque l'on teste une égalité, les primitifs sont comparés par leur valeur,
Les 2 objets que nous comparons n'ont pas ça : l'objet passé en paramètre fait référence à une zone mémoire différente que l'objet que nous utilisons pour faire la comparaison.
-C'est pourquoi l;es 2 conditions `{ ag: 18 } === { age: 18 }` et `{ age: 18 } == { age: 18 }` retournent `false`.
+C'est pourquoi les 2 conditions `{ age: 18 } === { age: 18 }` et `{ age: 18 } == { age: 18 }` retournent `false`.
From ec0eb68b2095f501330392b2aa68d331153ffb2a Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:31:05 +0200
Subject: [PATCH 149/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 29b0fb4d..137e5a91 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -626,7 +626,7 @@ getAge();
#### Réponse: C
-Avec `"use strict"`, vous pouvez êtes sûr de ne pas déclarer accidentellement des variables gloables. Nous ne déclarerons jamais la variable `age`, et temps que nous utiliserons `"use strict"`, cela créera une erreur de référence. Si nous n'utilisons pas `"use strict"`, cela fonctionnera et la variable `age` sont attribué à l'objet global.
+Avec `"use strict"`, vous pouvez êtes sûr de ne pas déclarer accidentellement des variables gloables. Nous ne déclarerons jamais la variable `age`, et temps que nous utiliserons `"use strict"`, cela créera une erreur de référence. Si nous n'utilisons pas `"use strict"`, cela fonctionnera et la variable `age` sera attribué à l'objet global.
From b7f9a72fec44e33e37969cc100acf9dd17f839e9 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:31:25 +0200
Subject: [PATCH 150/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 137e5a91..90c1f35d 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -731,7 +731,7 @@ set.has(1);
#### Réponse: C
-Toutes les clés d'objet (à l'exception des symboles) sont des chaînes de caratères sous le capot, même si vous ne les tapez pas vous-même en tant que chaîne. C'est pourquoi `obj.hasOwnProperty('1')` renvoie également la valeur `true`.
+Toutes les clés d'objet (à l'exception des symboles) sont des chaînes de caractères sous le capot, même si vous ne les tapez pas vous-même en tant que chaîne. C'est pourquoi `obj.hasOwnProperty("1")` renvoie également la valeur `true`.
Ça ne marche pas comme ça pour un set. Il n'y a pas de `'1'` dans notre ensemble : `set.has('1')` renvoie `false`. Il a le type numérique `1`, `set.has(1)` renvoie `true`.
From 6019dbd15115df850b622aab77cbaadb4e96a9e9 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:31:36 +0200
Subject: [PATCH 151/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 90c1f35d..5f5c1c52 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -764,7 +764,7 @@ Si vous avez deux clés portant le même nom, la clé sera remplacée. Elle sera
---
-###### 26. Le contexte global d'exécution de JavaScript créait 2 choses pour vous : l'objet global and le mot clé `this`.
+###### 26. Le contexte global d'exécution de JavaScript crée 2 choses pour vous : l'objet global and le mot-clé `this`.
- A: Vrai
- B: Faux
From aac9d3266154fcca2c267af12d178b65511fc449 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:31:58 +0200
Subject: [PATCH 152/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 5f5c1c52..ef45a77f 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -860,7 +860,7 @@ console.log(a[b]);
#### Réponse: B
-Les clés d'objet sont automatiquement converties en chaînes de caractère. Nous essayons de définir un objet en tant que clé de l'objet `a`, avec la valeur `123`.
+Les clés d'objet sont automatiquement converties en chaînes de caractères. Nous essayons de définir un objet en tant que clé de l'objet `a`, avec la valeur `123`.
Cependant, lorsque nous transformons un objet en chaine de caractère, il devient `"[Objet objet]"`. Donc, ce que nous disons ici, c'est que un `a["Objet objet"] = 123`. Ensuite, nous pouvons essayer de refaire la même chose. `c` est un autre objet que nous sommes implicitement en train de transformer en chaine de carctère. Donc, `a["Objet objet"] = 456`.
From f20b9ea38aff580f198d72916ee49ee95825ce09 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:32:24 +0200
Subject: [PATCH 153/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index ef45a77f..412a3534 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -2,7 +2,7 @@
Je poste quotidiennement des questions à choix multiple sur mon [Instagram](https://www.instagram.com/theavocoder), que je posterai aussi ici !
-Des basiques au avancée: testez vos connaissances en JavaScript, rafraichissez vos connaissances, ou préparez vous pour un entretien de code ! :muscle: :rocket: Je mets à jour ce dépôt chaque semaine avec des nouvelles questions.
+Des basiques au avancée : testez votre compréhension de JavaScript, rafraîchissez vos connaissances, ou préparez-vous pour un entretien technique ! :muscle: :rocket: Je mets à jour ce dépôt chaque semaine avec des nouvelles questions. Dernière mise à jour : 29 juin
Les réponses se trouvent dans les sections fermées en dessous des questions, cliquez simplement dessus pour les faire apparaitre. Bonne chance :heart:
From 149dba305a5e5edd8bd655ed7aefc6342f60128a Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:34:07 +0200
Subject: [PATCH 154/881] Update frnech introduction
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 412a3534..e236427b 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -2,7 +2,7 @@
Je poste quotidiennement des questions à choix multiple sur mon [Instagram](https://www.instagram.com/theavocoder), que je posterai aussi ici !
-Des basiques au avancée : testez votre compréhension de JavaScript, rafraîchissez vos connaissances, ou préparez-vous pour un entretien technique ! :muscle: :rocket: Je mets à jour ce dépôt chaque semaine avec des nouvelles questions. Dernière mise à jour : 29 juin
+De la base aux subtilités du langage : testez votre compréhension de JavaScript, rafraîchissez vos connaissances, ou préparez-vous pour un entretien technique ! :muscle: :rocket: Je mets à jour ce dépôt chaque semaine avec des nouvelles questions. Dernière mise à jour : [**29 juin**](#20190629)
Les réponses se trouvent dans les sections fermées en dessous des questions, cliquez simplement dessus pour les faire apparaitre. Bonne chance :heart:
From 8744ebff0ce2209881325cdc8ada7c5de005a683 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:34:52 +0200
Subject: [PATCH 155/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 412a3534..51d5bf57 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -38,7 +38,7 @@ sayHi();
Dans la fonction, nous déclarons en premier la variable `name` grâce au mot clé `var`. Cela signifie que la variable est "levée" _(hoisted)_ (l'espace mémoire est définie à la phase de création) avec pour valeur par défaut `undefined`, jusqu'à ce que le script atteigne la ligne de définition de la variable. Nous n'avons pas encore défini la variable lorsque nous essayons d'afficher la variable `name`, donc elle a toujours la valeur `undefined`.
-Les variables avec le mot clé `let` (et `const`) sont "levées" _(hoisted)_, mais contrairement à `var`, elle n'est pas initialisée. Elles ne sont pas accessible avant la ligne qui les declare (initialise). C'est appelé la "zone morte temporaire". Lorsque nous essayons d'accéder aux variables avant leur déclaration, JavaScript renvoit une `ReferenceError`.
+Les variables avec le mot clé `let` (et `const`) sont "levées" _(hoisted)_, mais contrairement à `var`, elle n'est pas initialisée. Elles ne sont pas accessible avant la ligne qui les déclare (initialise). C'est appelé la "zone morte temporaire". Lorsque nous essayons d'accéder aux variables avant leur déclaration, JavaScript renvoie une `ReferenceError`.
From c7c1cd6672ac05a5b1a4a25a8edf8b277bd7abea Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:35:12 +0200
Subject: [PATCH 156/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 51d5bf57..12633bb4 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -102,7 +102,7 @@ shape.perimeter();
Notez que la valeur de `diameter` est une fonction régulière, alors que celle de `perimeter` est une fonction fléchée.
-Avec les fonctions fléchée, le mot clé `this` réfère à son périmètre actuel, contrairement au fonctions régulières ! Cela signifie que lorsque nous appelons `perimeter`, elle ne réfère pas à l'objet shape, mais à son périmètre actuel (`window` par exemple).
+Avec les fonctions fléchée, le mot clé `this` réfère à son périmètre actuel, contrairement aux fonctions régulières ! Cela signifie que lorsque nous appelons `perimeter`, elle ne réfère pas à l'objet `shape`, mais à son périmètre actuel (`window` par exemple).
Il n'y a pas de valeur `radius` dans cet objet, on retournera `undefined`.
From 23d67024138466d65affebbd5d524c71e675d657 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:35:19 +0200
Subject: [PATCH 157/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 12633bb4..74f35a55 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -303,7 +303,7 @@ Pour éviter cela, on peut utiliser `"use strict"`. Cela nous assure de devoir d
---
-###### 10. Que ce passe-t-il lorsque nous faisons ça ?
+###### 10. Que se passe-t-il lorsque nous faisons ça ?
```javascript
function bark() {
From 721989e4717179ceed4b410683d5cdab2fc524d6 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:35:34 +0200
Subject: [PATCH 158/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 74f35a55..ac73533b 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -358,7 +358,7 @@ console.log(member.getFullName());
#### Réponse: A
-Vous ne pouvez pas ajouter de propriétés à un constructeur comme pour des objets normaux. Si vous voulez ajouter une fonctionnalité pour tout les objets en une fois, vous devez utiliser le prototype. Donc dans ce cas,
+Vous ne pouvez pas ajouter de propriétés à un constructeur comme pour des objets normaux. Si vous voulez ajouter une fonctionnalité pour tous les objets en une fois, vous devez utiliser le prototype. Donc dans ce cas,
```js
Person.prototype.getFullName = function() {
From 971ec71c31ee0b05c27e27bed275804ac2294eb0 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:35:40 +0200
Subject: [PATCH 159/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index ac73533b..cc7becda 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -428,7 +428,7 @@ Durant la phase de **capture** _(capturing)_, l'événement passe par les évén
---
-###### 14. Tous les objects ont des prototypes.
+###### 14. Tous les objets ont des prototypes.
- A: vrai
- B: faux
From 48aa14e4383c135a5fcb4d336de972463c4d5248 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:35:52 +0200
Subject: [PATCH 160/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index cc7becda..5278162b 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -438,7 +438,7 @@ Durant la phase de **capture** _(capturing)_, l'événement passe par les évén
#### Réponse: B
-Tous les objets ont des prototypes, excepté pour les **objets standards**. Les objets standards ont accès à certaines méthodes et propriétés, comme `.toString`. C'est pour cette raison que vous pouvez utiliser les méthodes natives de JavaScript ! Toutes ces méthodes sont disponibles dans le prototype. Bien que JavaScript ne trouve pas la fonction dans l'objet, il parcours le prototype et la méthode afin de la rendre accessible.
+Tous les objets ont des prototypes, excepté pour les **objets standards**. Les objets standards ont accès à certaines méthodes et propriétés, comme `.toString`. C'est pour cette raison que vous pouvez utiliser les méthodes natives de JavaScript ! Toutes ces méthodes sont disponibles dans le prototype. Bien que JavaScript ne trouve pas la fonction dans l'objet, il parcourt le prototype et la méthode afin de la rendre accessible.
From 1d47081c4ddfbeb2f3532049d06bde2e69d6248f Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:36:06 +0200
Subject: [PATCH 161/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 5278162b..81f93b65 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -534,7 +534,7 @@ getPersonInfo`${person} is ${age} years old`;
#### Réponse: B
-Si vous utilisez les template de chaine de caractère, la valeur du premier argument sera toujours un tableau de valeurs des chaines de caractère. Le reste des arguments seront les valeurs des expressions utilisées !
+Si vous utilisez les littéraux de gabarits, la valeur du premier argument sera toujours un tableau de valeurs des chaines de caractère. Le reste des arguments seront les valeurs des expressions utilisées !
From bc1011407c2d7e5c2f719e7e0b6141b69b7a39f3 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:36:21 +0200
Subject: [PATCH 162/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 81f93b65..e1ff905c 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -566,7 +566,7 @@ checkAge({ age: 18 });
#### Réponse: C
-Lorsque l'on teste une égalité, les primitifs sont comparés par leur valeur, alors que les objet sont comparés par leur _référence_. JavaScript vérifie si les objets ont une référence à la même zone de la mémoire.=
+Lorsque l'on teste une égalité, les primitifs sont comparés par leur valeur, alors que les objets sont comparés par leur _référence_. JavaScript vérifie si les objets ont une référence à la même zone de la mémoire.=
Les 2 objets que nous comparons n'ont pas ça : l'objet passé en paramètre fait référence à une zone mémoire différente que l'objet que nous utilisons pour faire la comparaison.
From 79517b0119922f8f170254aaec08c1642d15560d Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:37:00 +0200
Subject: [PATCH 163/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index e1ff905c..71cdeabe 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -830,7 +830,7 @@ name.giveLydiaPizza();
#### Réponse: A
-`String` est un constructeur intégré, auquel nous pouvons ajouter des propriétés. Je viens d'ajouter une méthode à son prototype. Les chaînes de caratère primitives sont automatiquement converties en un objet chaîne, généré par la fonction prototype de chaîne. Ainsi, toutes les chaînes (objets de chaîne) ont accès à cette méthode !
+`String` est un constructeur intégré, auquel nous pouvons ajouter des propriétés. Je viens d'ajouter une méthode à son prototype. Les chaînes de caractère primitives sont automatiquement converties en un objet chaîne, généré par la fonction prototype de chaîne. Ainsi, toutes les chaînes (objets de chaîne) ont accès à cette méthode !
From a2fce6a87a032d0d8aab7b23030600935e4d0ae4 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:37:17 +0200
Subject: [PATCH 164/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 71cdeabe..b5117d31 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -924,7 +924,7 @@ C'est ici qu'une boucle d'événement commence à fonctionner. La **boucle d'év
---
-###### 31. Quel est l'élément ciblé _(event.target)_ au click sur le bouton _(button)_ ?
+###### 31. Quel est l'élément ciblé _(event.target)_ au clic sur le bouton _(button)_ ?
```html
From c29fc7fb50f18f84bb5bcff838f7df63c5b031bd Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:37:28 +0200
Subject: [PATCH 165/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index b5117d31..9557e0f0 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -1005,7 +1005,7 @@ sayHi.bind(person, 21);
Avec les deux, nous pouvons transmettre l'objet auquel nous voulons que le mot clé `this` fasse référence. Cependant, `.call` est aussi _exécuté immédiatement_ !
-`.bind.` renvoie une copie de la fonction, mais avec un contexte lié ! Elle n'est pas exécuté immédiatement.
+`.bind.` renvoie une copie de la fonction, mais avec un contexte lié ! Elle n'est pas exécutée immédiatement.
From f6f8988983bc229a921e34420c9c9b5f6c122d70 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:38:04 +0200
Subject: [PATCH 166/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 9557e0f0..bab04970 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -1184,7 +1184,7 @@ JavaScript n'a que des types et des objets primitifs.
Les types primitifs sont `boolean`, `null`, `undefined`, `bigint`, `number`, `string` et `symbol`.
-Ce qui différencie une primitive d'un objet, c'est que les primitives n'ont aucune propriété ou méthode. Cependant, vous remarquerez que `'foo'.toUpperCase()` est évalué à `'FOO'` et n'entraîne pas de `TypeError`. En effet, lorsque vous essayez d'accéder à une propriété ou à une méthode sur une primitive telle qu'une chaîne, JavaScript encapsule implicitement l'objet à l'aide de l'une des classes d'encapsuleur, à savoir `String`, puis supprime immédiatement l'encapsuleur après l'évaluation de l'expression. Toutes les primitives à l'exception de `null` et` undefined` présentent ce comportement.
+Ce qui différencie une primitive d'un objet, c'est que les primitives n'ont aucune propriété ou méthode. Cependant, vous remarquerez que `'foo'.toUpperCase()` est évalué à `'FOO'` et n'entraîne pas de `TypeError`. En effet, lorsque vous essayez d'accéder à une propriété ou à une méthode sur une primitive telle qu'une chaîne, JavaScript encapsule implicitement l'objet à l'aide de l'une des classes d'encapsulation, à savoir `String`, puis supprime immédiatement l'encapsulation après l'évaluation de l'expression. Toutes les primitives à l'exception de `null` et` undefined` présentent ce comportement.
From 7ffd89070530781bd8057d86d0e12bf3c1e7a756 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:38:14 +0200
Subject: [PATCH 167/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index bab04970..91590973 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -1289,7 +1289,7 @@ Il retourne un identifiant unique. Cet identifiant peut être utilisé pour effa
#### Réponse: A
-Une chaîne de caractère est itérable. L'opérateur de desconstruction transforme chaque caractère d'un itérable en un élément.
+Une chaîne de caractère est itérable. L'opérateur de déconstruction transforme chaque caractère d'un itérable en un élément.
From d4dce83098b2603c60b5af10fe9228be7b0d854e Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:38:27 +0200
Subject: [PATCH 168/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 91590973..ade4973f 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -597,7 +597,7 @@ getAge(21);
#### Réponse: C
-L'opérateur de destructuration _(spread operator)_ (`...args`) retourne un tableau avec les arguments. Un tableau est un objet, donc `typeof args` retournera `"object"`.
+L'opérateur de déstructuration _(spread operator)_ (`...args`) retourne un tableau avec les arguments. Un tableau est un objet, donc `typeof args` retournera `"object"`.
From cdaca3fceedb6d6ef5d82633fad8a85332e40363 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:39:54 +0200
Subject: [PATCH 169/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index ade4973f..3c7d86be 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -649,7 +649,7 @@ const sum = eval("10*10+5");
#### Réponse: A
-`eval` évalue les codes que nous passons en paramétre de type chaine de caractères. Si c'est une expression, comme dans notre cas, il évaluera l'expression. L'expression est `10 * 10 + 5`, ce qui retourne le nombre `105`.
+`eval` évalue les codes que nous passons en paramètre de type chaîne de caractères. Si c'est une expression, comme dans notre cas, il évaluera l'expression. L'expression est `10 * 10 + 5`, ce qui retourne le nombre `105`.
From ad09fb44d3ca560878604ec1d575529ea4e25310 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:40:10 +0200
Subject: [PATCH 170/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 3c7d86be..92768437 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -231,7 +231,7 @@ console.log(b === c);
#### Réponse: C
-`new Number()` est une fonction globale. Bien qu'il ressemble à un nombre, ce n'en est pas vraiment un : il a une poignée de fonctionnalités supplémentaire and est un objet.
+`new Number()` est une fonction globale. Bien qu'il ressemble à un nombre, ce n'en est pas vraiment un : il a une poignée de fonctionnalités supplémentaire et est un objet.
Quand nous utilisons l'opérateur `==`, il vérifie seulement qu'il s'agisse de la même _valeur_. Les deux ont pour valeur `3`, donc il retourne `true`.
From 70dc00e6a338abc3daa80f47775b0077b957b672 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:40:36 +0200
Subject: [PATCH 171/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 92768437..231a7c4f 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -4,7 +4,7 @@ Je poste quotidiennement des questions à choix multiple sur mon [Instagram](htt
Des basiques au avancée : testez votre compréhension de JavaScript, rafraîchissez vos connaissances, ou préparez-vous pour un entretien technique ! :muscle: :rocket: Je mets à jour ce dépôt chaque semaine avec des nouvelles questions. Dernière mise à jour : 29 juin
-Les réponses se trouvent dans les sections fermées en dessous des questions, cliquez simplement dessus pour les faire apparaitre. Bonne chance :heart:
+Les réponses se trouvent dans les sections repliées en dessous des questions, cliquez simplement dessus pour les faire apparaître. Bonne chance :heart:
[English](./README.md)
[中文版本](./README-zh_CN.md)
From 365bae5590177b62f5b6414895bc7cf05641c2e5 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:40:56 +0200
Subject: [PATCH 172/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 231a7c4f..a7430f9a 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -656,7 +656,7 @@ const sum = eval("10*10+5");
---
-###### 22. Pendant combien de temps `cool_secret` sera-t'il accessible ?
+###### 22. Pendant combien de temps `cool_secret` sera-t-il accessible ?
```javascript
sessionStorage.setItem("cool_secret", 123);
From 0ae3d290213d7aef751200d1d4f11b3b4f8f910c Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:41:10 +0200
Subject: [PATCH 173/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index a7430f9a..cf159372 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -702,7 +702,7 @@ console.log(num);
Avec le mot clé `var`, vous pouvez déclarer plusieurs variables avec le même nom. La variable aura pour valeur la dernière assignée.
-Vous ne pouvez par faire cela avec `let` ou `const` puisqu'ils ont une portée de bloc.
+Vous ne pouvez pas faire cela avec `let` ou `const` puisqu'ils ont une portée de bloc.
From d7e6f5b518b707a079de9f463af9b6b8861ea655 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:41:24 +0200
Subject: [PATCH 174/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index cf159372..f90f179d 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -775,7 +775,7 @@ Si vous avez deux clés portant le même nom, la clé sera remplacée. Elle sera
#### Réponse: A
-Le contexte d'exécution de base est le contexte d'exécution global: c'est ce qui est accessible partout dans votre code.
+Le contexte d'exécution de base est le contexte d'exécution global : c'est ce qui est accessible partout dans votre code.
From dc3a806703c4a407baa36a30f31f1895fccab190 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:41:35 +0200
Subject: [PATCH 175/881] Update README_fr-FR.md
Co-Authored-By: Quentin Tomasicchio
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index f90f179d..ff868b4f 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -768,7 +768,7 @@ Si vous avez deux clés portant le même nom, la clé sera remplacée. Elle sera
- A: Vrai
- B: Faux
-- C: Ça dépends
+- C: Ça dépend
Réponse
From fb8cd698df92436fab9f9da3d0d4f964ac81f5e7 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:41:59 +0200
Subject: [PATCH 176/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index ff868b4f..5e0a8857 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -235,7 +235,7 @@ console.log(b === c);
Quand nous utilisons l'opérateur `==`, il vérifie seulement qu'il s'agisse de la même _valeur_. Les deux ont pour valeur `3`, donc il retourne `true`.
-Cependant, quand on utilise l'opérateur `===`, les 2 valeurs _et_ type doivent être les même. `new Number()` n'est pas un nombre, c'est un **objet**, il retourne `false`.
+Cependant, quand on utilise l'opérateur `===`, les 2 valeurs _et_ types doivent être les mêmes. `new Number()` n'est pas un nombre, c'est un **objet**, il retourne `false`.
From ae3e57b0bb06e10612a9b95361d0555f39511d3d Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:42:24 +0200
Subject: [PATCH 177/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 5e0a8857..24128677 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -270,7 +270,7 @@ freddie.colorChange("orange");
#### Réponse: D
-La fonction `colorChange` est statique. Les méthodes statiques sont désignée pour vivre seulement dans le constructeur qui les a créer et ne peuvent pas être transférer aux enfants. Comme `freddie` est un enfant, la fonction n'est pas transférée et non disponible dans l'instance de `freddie` : une erreur `TypeError` est renvoyée.
+La fonction `colorChange` est statique. Les méthodes statiques sont désignées pour vivre seulement dans le constructeur qui les a créé et ne peuvent pas être transférer aux enfants. Comme `freddie` est un enfant, la fonction n'est pas transférée et n'est pas disponible dans l'instance de `freddie` : une erreur `TypeError` est renvoyée.
From d341173368448b7921b784f38baf9d46820f73b8 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:42:41 +0200
Subject: [PATCH 178/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 24128677..80012ae7 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -294,7 +294,7 @@ console.log(greetign);
#### Réponse: A
-Il affiche l'objet, car on a juste créé un objet vide dnas l'objet global ! Quand on écrit mal `greeting` en `greetign`, JaveScript l'interprète comme il le voit `global.greetign = {}` (ou `window.greetign = {}` dans le navigateur).
+Il affiche l'objet, car on a juste créé un objet vide dans l'objet global ! Quand on écrit mal `greeting` en `greetign`, JavaScript l'interprète comme il le voit `global.greetign = {}` (ou `window.greetign = {}` dans le navigateur).
Pour éviter cela, on peut utiliser `"use strict"`. Cela nous assure de devoir déclarer la variable avant de lui assigné une valeur.
From 40dff9f36bffc99d3f7dc3809c118301bde80e92 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:42:55 +0200
Subject: [PATCH 179/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 80012ae7..872a71eb 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -296,7 +296,7 @@ console.log(greetign);
Il affiche l'objet, car on a juste créé un objet vide dans l'objet global ! Quand on écrit mal `greeting` en `greetign`, JavaScript l'interprète comme il le voit `global.greetign = {}` (ou `window.greetign = {}` dans le navigateur).
-Pour éviter cela, on peut utiliser `"use strict"`. Cela nous assure de devoir déclarer la variable avant de lui assigné une valeur.
+Pour éviter cela, on peut utiliser `"use strict"`. Cela nous assure de devoir déclarer la variable avant de lui assigner une valeur.
From bce2b12b982e56ad788eea6804f840b03f494295 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:43:12 +0200
Subject: [PATCH 180/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 872a71eb..688b805a 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -325,7 +325,7 @@ bark.animal = "dog";
C'est possible en JavaScript, car les fonctions sont des objets ! (Tout ce qui n'est pas de type primitif est un objet)
-Une fonction est un type special d'objet. Le code que vous écrivez vous-même n'est pas la fonction. La fonction est un objet avec des propriétées. Cette propriétée est invocable.
+Une fonction est un type spécial d'objet. Le code que vous écrivez vous-même n'est pas la fonction. La fonction est un objet avec des propriétés. Cette propriété est invocable.
From cf7f1f49b347939aeef719131b8536250afe0003 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:43:37 +0200
Subject: [PATCH 181/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 688b805a..4a762115 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -467,7 +467,7 @@ sum(1, "2");
JavaScript est un **langage à types dynamiques** : nous n'avons pas besoin de spécifier le types des variables. Les valeurs peuvent être automatiquement convertir vers les autres types sans que vous le sachiez, c'est ce que l'on appelle _la conversion de types implicites_ _(implicit type coercion)_.
-Dans cette exemple, JavaScript convertit le nombre `1` en un chaine de caractère, afin que la fonction est du sens et puisse renvoyer un valeur. Durant l'addition d'un type numérique (`1`) et d'un type chaine de caractère (`'2'`), le nombre est traité comme une chaine de caractère. Nous pouvons concaténer les chaines de caractères comme `"Hello" + "World"`, c'est donc ce qui arrive ici avec `"1" + "2"` qui retourne `"12"`.
+Dans cette exemple, JavaScript convertit le nombre `1` en un chaine de caractère, afin que la fonction ait du sens et puisse renvoyer une valeur. Durant l'addition d'un type numérique (`1`) et d'un type chaine de caractère (`'2'`), le nombre est traité comme une chaine de caractère. Nous pouvons concaténer les chaines de caractères comme `"Hello" + "World"`, c'est donc ce qui arrive ici avec `"1" + "2"` qui retourne `"12"`.
From 3da6cdb3a8f6c3fc8bc2b3654efa2e17bb2d2ddd Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:43:59 +0200
Subject: [PATCH 182/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 4a762115..5f875098 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -366,7 +366,7 @@ Person.prototype.getFullName = function() {
};
```
-rendra fonctionnel `member.getFullName`. Pourquoi est-ce benifique ? Disons que nous ajoutons cette méthode au constructeur directement. Peut-être que toutes les instances de `Person` n'ont pas besoin de cette méthode. Cela fera perdre de l'espace mémoire, car elles auront tous cette propriété, ce qui prendra de l'espace mémoire pour chaque instance. Alors que, si nous ajoutons la méthode au prototype uniquement, nous n'utilisons qu'un seul slot mémoire, et ils y auront tous accès !
+rendra fonctionnel `member.getFullName`. Pourquoi est-ce bénéfique ? Disons que nous ajoutons cette méthode au constructeur directement. Peut-être que toutes les instances de `Person` n'ont pas besoin de cette méthode. Cela fera perdre de l'espace mémoire, car elles auront tous cette propriété, ce qui prendra de l'espace mémoire pour chaque instance. Alors que, si nous ajoutons la méthode au prototype uniquement, nous n'utilisons qu'un seul slot mémoire, et ils y auront tous accès !
From 3468e7816f8ba9a253c7546c043923aba1ed235b Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:44:19 +0200
Subject: [PATCH 183/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 5f875098..a8b27659 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -398,7 +398,7 @@ console.log(sarah);
#### Réponse: A
-Pour `sarah`, nous n'avons pas utilisé le mot clé `new`. Quand nous utilisons `new`, il fait référence à un nouvel objet vide que nous créons. Cependant so nous n'ajoutons pas `new` il réfère à **l'objet global** !
+Pour `sarah`, nous n'avons pas utilisé le mot clé `new`. Quand nous utilisons `new`, il fait référence à un nouvel objet vide que nous créons. Cependant, nous n'ajoutons pas `new`. Il réfère à **l'objet global** !
Nous disons que `this.firstName` est égal à `"Sarah"` et que `this.lastName` est égal à `Smith`. Ce que nous faisons c'est définir `global.firstName = 'Sarah'` et `global.lastName = 'Smith'`. La variable `sarah` elle-même reste à `undefined`.
From e21d743c8d109b86f5d330fc69df471cdd239651 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:44:35 +0200
Subject: [PATCH 184/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index a8b27659..349c540b 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -419,7 +419,7 @@ Nous disons que `this.firstName` est égal à `"Sarah"` et que `this.lastName` e
#### Réponse: D
-Durant la phase de **capture** _(capturing)_, l'événement passe par les événements parent jusqu'à l'élément ciblé. Il attient ensuite l'élément **ciblé** _(target)_, et commence à **bouillonner** _(bubbling)_.
+Durant la phase de **capture** _(capturing)_, l'événement passe par les éléments parents jusqu'à l'élément ciblé. Il atteint ensuite l'élément **ciblé** _(target)_, et commence à **bouillonner** _(bubbling)_.
From a7f5c3cfa1d7ba6867729893c7869c51dc13b615 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 21:44:54 +0200
Subject: [PATCH 185/881] Update README_fr-FR.md
Co-Authored-By: Nathanael CHERRIER
---
README_fr-FR.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 349c540b..7a7aded1 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -465,7 +465,7 @@ sum(1, "2");
#### Réponse: C
-JavaScript est un **langage à types dynamiques** : nous n'avons pas besoin de spécifier le types des variables. Les valeurs peuvent être automatiquement convertir vers les autres types sans que vous le sachiez, c'est ce que l'on appelle _la conversion de types implicites_ _(implicit type coercion)_.
+JavaScript est un **langage à types dynamiques** : nous n'avons pas besoin de spécifier le types des variables. Les valeurs peuvent être automatiquement converties vers les autres types sans que vous le sachiez, c'est ce que l'on appelle _la conversion de types implicites_ _(implicit type coercion)_.
Dans cette exemple, JavaScript convertit le nombre `1` en un chaine de caractère, afin que la fonction ait du sens et puisse renvoyer une valeur. Durant l'addition d'un type numérique (`1`) et d'un type chaine de caractère (`'2'`), le nombre est traité comme une chaine de caractère. Nous pouvons concaténer les chaines de caractères comme `"Hello" + "World"`, c'est donc ce qui arrive ici avec `"1" + "2"` qui retourne `"12"`.
From 7b027c51b8e5c31111a8a3b63e7ef3c301718567 Mon Sep 17 00:00:00 2001
From: Tanguy Coppin
Date: Thu, 4 Jul 2019 22:11:58 +0200
Subject: [PATCH 186/881] FR : Translate the first 63 questions
---
README.md | 1 +
README_fr-FR.md | 760 +++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 713 insertions(+), 48 deletions(-)
diff --git a/README.md b/README.md
index d4fffadb..687b0c24 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,7 @@ List of available languages:
* [Tiếng Việt](./README-vi.md)
* [Українська мова](./README-ua_UA.md)
* [Português Brasil](./README_pt_BR.md)
+* [Français](./README_fr-FR.md)
---
diff --git a/README_fr-FR.md b/README_fr-FR.md
index 5c5c234f..9dc016b9 100644
--- a/README_fr-FR.md
+++ b/README_fr-FR.md
@@ -6,10 +6,17 @@ De la base aux subtilités du langage : testez votre compréhension de JavaScrip
Les réponses se trouvent dans les sections repliées en dessous des questions, cliquez simplement dessus pour les faire apparaître. Bonne chance :heart:
-[English](./README.md)
-[中文版本](./README-zh_CN.md)
-[Русский](./README_ru-RU.md)
-[Western Balkan](./README-bs.md)
+* [English](./README.md)
+* [中文版本](./README-zh_CN.md)
+* [Versión en español](./README-ES.md)
+* [日本語](./README-ja_JA.md)
+* [한국어](./README-ko_KR.md)
+* [Русский](./README_ru-RU.md)
+* [Western Balkan](./README-bs_BS.md)
+* [Deutsch](./README-de_DE.md)
+* [Tiếng Việt](./README-vi.md)
+* [Українська мова](./README-ua_UA.md)
+* [Português Brasil](./README_pt_BR.md)
---
@@ -34,7 +41,7 @@ sayHi();
Réponse
-#### Réponse: D
+#### Réponse : D
Dans la fonction, nous déclarons en premier la variable `name` grâce au mot clé `var`. Cela signifie que la variable est "levée" _(hoisted)_ (l'espace mémoire est définie à la phase de création) avec pour valeur par défaut `undefined`, jusqu'à ce que le script atteigne la ligne de définition de la variable. Nous n'avons pas encore défini la variable lorsque nous essayons d'afficher la variable `name`, donc elle a toujours la valeur `undefined`.
@@ -64,7 +71,7 @@ for (let i = 0; i < 3; i++) {
Réponse
-#### Réponse: C
+#### Réponse : C
À cause du système de queue dans JavaScript, la fonction de rappel _(callback)_ du `setTimeout` est appelée _après_ que la boucle soit exécutée. Comme la variable `i` dans la première boucle est déclarée avec le mot-clé `var`, c'est une variable globale. Pendant la boucle, nous incrémentons la valeur de `i` de `1` à chaque fois, en utilisant l'opérateur arithmétique `++`. Lorsque la fonction de rappel _(callback)_ du `setTimeout` est invoquée, `i` est égal à `3` dans le premier exemple.
@@ -98,7 +105,7 @@ shape.perimeter();
Réponse
-#### Réponse: B
+#### Réponse : B
Notez que la valeur de `diameter` est une fonction régulière, alors que celle de `perimeter` est une fonction fléchée.
@@ -125,7 +132,7 @@ Il n'y a pas de valeur `radius` dans cet objet, on retournera `undefined`.
Réponse
-#### Réponse: A
+#### Réponse : A
L'opérateur arithmétique `+` essait de convertir un opérande en une valeur numérique. `true` devient `1`, et `false` devient `0`.
@@ -157,7 +164,7 @@ const mouse = {
Réponse
-#### Réponse: A
+#### Réponse : A
En JavaScript, toutes les clés d'objet sont des chaines de caractères (sauf si c'est un Symbol). Bien que nous ne puissions pas les _typer_ comme des chaines de caractères, elles sont converties en chaines de caractères sous le capot.
@@ -194,7 +201,7 @@ console.log(d.greeting);
Réponse
-#### Réponse: A
+#### Réponse : A
En JavaScript, tous les objets interagissent par _référence_ lorsqu'on les définit égaux les uns aux autres.
@@ -229,7 +236,7 @@ console.log(b === c);
Réponse
-#### Réponse: C
+#### Réponse : C
`new Number()` est une fonction globale. Bien qu'il ressemble à un nombre, ce n'en est pas vraiment un : il a une poignée de fonctionnalités supplémentaire et est un objet.
@@ -268,7 +275,7 @@ freddie.colorChange("orange");
Réponse
-#### Réponse: D
+#### Réponse : D
La fonction `colorChange` est statique. Les méthodes statiques sont désignées pour vivre seulement dans le constructeur qui les a créé et ne peuvent pas être transférer aux enfants. Comme `freddie` est un enfant, la fonction n'est pas transférée et n'est pas disponible dans l'instance de `freddie` : une erreur `TypeError` est renvoyée.
@@ -292,7 +299,7 @@ console.log(greetign);
Réponse
-#### Réponse: A
+#### Réponse : A
Il affiche l'objet, car on a juste créé un objet vide dans l'objet global ! Quand on écrit mal `greeting` en `greetign`, JavaScript l'interprète comme il le voit `global.greetign = {}` (ou `window.greetign = {}` dans le navigateur).
@@ -321,7 +328,7 @@ bark.animal = "dog";
Réponse
-#### Réponse: A
+#### Réponse : A
C'est possible en JavaScript, car les fonctions sont des objets ! (Tout ce qui n'est pas de type primitif est un objet)
@@ -356,7 +363,7 @@ console.log(member.getFullName());
Réponse
-#### Réponse: A
+#### Réponse : A
Vous ne pouvez pas ajouter de propriétés à un constructeur comme pour des objets normaux. Si vous voulez ajouter une fonctionnalité pour tous les objets en une fois, vous devez utiliser le prototype. Donc dans ce cas,
@@ -396,7 +403,7 @@ console.log(sarah);
Réponse
-#### Réponse: A
+#### Réponse : A
Pour `sarah`, nous n'avons pas utilisé le mot clé `new`. Quand nous utilisons `new`, il fait référence à un nouvel objet vide que nous créons. Cependant, nous n'ajoutons pas `new`. Il réfère à **l'objet global** !
@@ -417,7 +424,7 @@ Nous disons que `this.firstName` est égal à `"Sarah"` et que `this.lastName` e
Réponse
-#### Réponse: D
+#### Réponse : D
Durant la phase de **capture** _(capturing)_, l'événement passe par les éléments parents jusqu'à l'élément ciblé. Il atteint ensuite l'élément **ciblé** _(target)_, et commence à **bouillonner** _(bubbling)_.
@@ -436,7 +443,7 @@ Durant la phase de **capture** _(capturing)_, l'événement passe par les élém
Réponse
-#### Réponse: B
+#### Réponse : B
Tous les objets ont des prototypes, excepté pour les **objets standards**. Les objets standards ont accès à certaines méthodes et propriétés, comme `.toString`. C'est pour cette raison que vous pouvez utiliser les méthodes natives de JavaScript ! Toutes ces méthodes sont disponibles dans le prototype. Bien que JavaScript ne trouve pas la fonction dans l'objet, il parcourt le prototype et la méthode afin de la rendre accessible.
@@ -463,7 +470,7 @@ sum(1, "2");
Réponse
-#### Réponse: C
+#### Réponse : C
JavaScript est un **langage à types dynamiques** : nous n'avons pas besoin de spécifier le types des variables. Les valeurs peuvent être automatiquement converties vers les autres types sans que vous le sachiez, c'est ce que l'on appelle _la conversion de types implicites_ _(implicit type coercion)_.
@@ -491,7 +498,7 @@ console.log(number);
Réponse
-#### Réponse: C
+#### Réponse : C
L'opérateur arithmétique **postfix** `++` :
@@ -532,7 +539,7 @@ getPersonInfo`${person} is ${age} years old`;
Réponse
-#### Réponse: B
+#### Réponse : B
Si vous utilisez les littéraux de gabarits, la valeur du premier argument sera toujours un tableau de valeurs des chaines de caractère. Le reste des arguments seront les valeurs des expressions utilisées !
@@ -564,7 +571,7 @@ checkAge({ age: 18 });
Réponse
-#### Réponse: C
+#### Réponse : C
Lorsque l'on teste une égalité, les primitifs sont comparés par leur valeur, alors que les objets sont comparés par leur _référence_. JavaScript vérifie si les objets ont une référence à la même zone de la mémoire.=
@@ -595,9 +602,9 @@ getAge(21);
Réponse
-#### Réponse: C
+#### Réponse : C
-L'opérateur de déstructuration _(spread operator)_ (`...args`) retourne un tableau avec les arguments. Un tableau est un objet, donc `typeof args` retournera `"object"`.
+La syntaxe des paramètres du reste _(rest parameters)_ (`...args`) retourne un tableau avec les arguments. Un tableau est un objet, donc `typeof args` retournera `"object"`.
@@ -624,7 +631,7 @@ getAge();
Réponse
-#### Réponse: C
+#### Réponse : C
Avec `"use strict"`, vous pouvez êtes sûr de ne pas déclarer accidentellement des variables gloables. Nous ne déclarerons jamais la variable `age`, et temps que nous utiliserons `"use strict"`, cela créera une erreur de référence. Si nous n'utilisons pas `"use strict"`, cela fonctionnera et la variable `age` sera attribué à l'objet global.
@@ -647,7 +654,7 @@ const sum = eval("10*10+5");
Réponse
-#### Réponse: A
+#### Réponse : A
`eval` évalue les codes que nous passons en paramètre de type chaîne de caractères. Si c'est une expression, comme dans notre cas, il évaluera l'expression. L'expression est `10 * 10 + 5`, ce qui retourne le nombre `105`.
@@ -670,7 +677,7 @@ sessionStorage.setItem("cool_secret", 123);
Réponse
-#### Réponse: B
+#### Réponse : B
La donnée stocké dans le `sessionStorage` est supprimée après la fermeture de l'onglet.
@@ -698,7 +705,7 @@ console.log(num);
Réponse
-#### Réponse: B
+#### Réponse : B
Avec le mot clé `var`, vous pouvez déclarer plusieurs variables avec le même nom. La variable aura pour valeur la dernière assignée.
@@ -729,7 +736,7 @@ set.has(1);
Réponse
-#### Réponse: C
+#### Réponse : C
Toutes les clés d'objet (à l'exception des symboles) sont des chaînes de caractères sous le capot, même si vous ne les tapez pas vous-même en tant que chaîne. C'est pourquoi `obj.hasOwnProperty("1")` renvoie également la valeur `true`.
@@ -755,7 +762,7 @@ console.log(obj);
Réponse
-#### Réponse: C
+#### Réponse : C
Si vous avez deux clés portant le même nom, la clé sera remplacée. Elle sera toujours dans sa première position, mais avec la dernière valeur spécifiée.
@@ -773,7 +780,7 @@ Si vous avez deux clés portant le même nom, la clé sera remplacée. Elle sera
Réponse
-#### Réponse: A
+#### Réponse : A
Le contexte d'exécution de base est le contexte d'exécution global : c'est ce qui est accessible partout dans votre code.
@@ -799,7 +806,7 @@ for (let i = 1; i < 5; i++) {
Réponse
-#### Réponse: C
+#### Réponse : C
L'instruction `continue` ignore une itération si une condition donnée renvoie `true`.
@@ -828,7 +835,7 @@ name.giveLydiaPizza();
Réponse
-#### Réponse: A
+#### Réponse : A
`String` est un constructeur intégré, auquel nous pouvons ajouter des propriétés. Je viens d'ajouter une méthode à son prototype. Les chaînes de caractère primitives sont automatiquement converties en un objet chaîne, généré par la fonction prototype de chaîne. Ainsi, toutes les chaînes (objets de chaîne) ont accès à cette méthode !
@@ -858,7 +865,7 @@ console.log(a[b]);
Réponse
-#### Réponse: B
+#### Réponse : B
Les clés d'objet sont automatiquement converties en chaînes de caractères. Nous essayons de définir un objet en tant que clé de l'objet `a`, avec la valeur `123`.
@@ -891,7 +898,7 @@ baz();
Réponse
-#### Réponse: B
+#### Réponse : B
Nous avons une fonction `setTimeout` et nous l'avons d'abord appelée. Pourtant, il a été affiché en dernier.
@@ -944,7 +951,7 @@ C'est ici qu'une boucle d'événement commence à fonctionner. La **boucle d'év