Skip to content

Instantly share code, notes, and snippets.

@DavidPeralvarez
Created March 24, 2020 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidPeralvarez/50672fb99a446a9619be08cf1495fea5 to your computer and use it in GitHub Desktop.
Save DavidPeralvarez/50672fb99a446a9619be08cf1495fea5 to your computer and use it in GitHub Desktop.
JavaScript - Asignación por valor o por referencia
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Curso de Javascript</title>
</head>
<body>
<script src="scripts.js"></script>
</body>
</html>
/* Objetos */
var perro = {
nombre: 'Mel',
edad: 4,
raza: 'Border Collie',
adoptado: true,
dueno: {
nombre: 'David',
apellido: 'Perálvarez',
direccion: {
calle: 'Falsa',
numero: 123,
ciudad: 'Springfield'
},
telefono: '3424234234'
},
sociable: true
};
// var perro2 = perro,
// perro3 = perro2;
// console.log( perro, perro2 );
// perro2.nombre = 'Nua';
// perro3.nombre = 'Dac';
// console.log( perro, perro2, perro3 );
perro.patita = true;
console.log( perro );
var direccion = perro.dueno.direccion;
console.log( direccion );
direccion.calle = 'Cierta';
console.log( perro );
// var smartphone1 = 'iPhone',
// smartphone2 = smartphone1;
// console.log( smartphone1, smartphone2 );
// smartphone2 = 'Xiaomi';
// console.log( smartphone1, smartphone2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment