This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pessoa = { | |
nome: 'Marcos', | |
contatos: { | |
email: 'coder.marcos@gmail.com' | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pessoa = { | |
nome: 'Marcos', | |
contatos: { | |
email: 'coder.marcos@gmail.com' | |
} | |
}; | |
var clone = pessoa; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pessoa = { | |
nome: 'Marcos', | |
contatos: { | |
email: 'coder.marcos@gmail.com' | |
} | |
}; | |
console.log('pessoa', pessoa); | |
var clone = pessoa; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = {}; | |
var b = {}; | |
a.b = b; // Cria a referencia em a para o B | |
b.a = a; // Cria a referencia em b para o A, | |
console.log(a); | |
// a: Object { b: [circular object] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = {}; | |
var b = {}; | |
a.b = b; // Cria a referencia em a para o B | |
b.a = a; // Cria a referencia em b para o A, | |
console.log(a); | |
// a: Object { b: [circular object] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = {}; | |
var b = {}; | |
a.b = b; // Cria a referencia em a para o B | |
b.a = a; // Cria a referencia em b para o A | |
JSON.stringifyCiclic = (json) => { | |
var seen = []; | |
var replacer = (key, value) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function teste() { | |
var a = {}; | |
var b = {}; | |
a.b = b; // Cria a referencia em a para o B | |
b.a = a; // Cria a referencia em b para o A | |
return 'qualquer coisa'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pessoa = { | |
nome: 'Marcos', | |
contatos: { | |
email: 'coder.marcos@gmail.com' | |
} | |
}; | |
var clone = { | |
nome: pessoa.nome, | |
contatos: pessoa.contatos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pessoa = { | |
nome: 'Marcos', | |
contatos: { | |
email: 'coder.marcos@gmail.com' | |
} | |
}; | |
var clone = { | |
nome: pessoa.nome, | |
contatos: pessoa.contatos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pessoa = { nome: 'Marcos' }; | |
var clone = Object.assign({}, pessoa); | |
pessoa.idade = 19; | |
console.log('pessoa', pessoa); | |
// "pessoa" Object { nome: "Marcos", idade: 19 } | |
console.log('clone', clone); | |
// "clone" Object { nome: "Marcos" } |
OlderNewer