Instagram | Twitter | LinkedIn
What is the output of the following code ?
Click here to see the correct answer and explanation 馃憖
| Correct Answer | Explanation |
|---|---|
| C | The Object.preventExtensions() method prevents the addition of new properties to our existing object. preventExtensions() is a irreversible operation. We can never add extra properties to the object again. |
Explanation based on 馃憠馃徏 Creating immutable objects in native JavaScript | JS Tips
Code:
const bestDinner = {
hamburger: "馃崝",
frenchFries: "馃崯",
soda: "馃イ"
};
Object.preventExtensions(bestDinner);
bestDinner.salad = "馃";
console.log(bestDinner.salad);
驴Qu茅 imprime el siguiente c贸digo?
Haz click aqu铆 para ver la respuesta correcta y su explicaci贸n 馃憖
| Respuesta correcta | Explicaci贸n |
|---|---|
| C | El m茅todo Object.preventExtensions() evita la adici贸n de nuevas propiedades a nuestro objeto existente. preventExtensions() es una operaci贸n irreversible. Nunca m谩s podremos agregar propiedades adicionales al objeto. |
Explicaci贸n basada en 馃憠馃徏 Creating immutable objects in native JavaScript | JS Tips
C贸digo:
const bestDinner = {
hamburger: "馃崝",
frenchFries: "馃崯",
soda: "馃イ"
};
Object.preventExtensions(bestDinner);
bestDinner.salad = "馃";
console.log(bestDinner.salad);

