Skip to content

Instantly share code, notes, and snippets.

@teffcode
Created October 5, 2020 00:08
Show Gist options
  • Select an option

  • Save teffcode/7874386bd3dc22e658f63d8ee0ede970 to your computer and use it in GitHub Desktop.

Select an option

Save teffcode/7874386bd3dc22e658f63d8ee0ede970 to your computer and use it in GitHub Desktop.

馃憢馃徏 Welcome 馃憢馃徏

Quiz banner

Instagram | Twitter | LinkedIn


Choose your language 馃憛



English version 馃殌


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);


Spanish version 馃殌


驴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);


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment