1
I made this code to study Javascript Proxy. It works by detecting the change of the object’s property but when I call the property on the console.log it does not appear changed
JS
var f = {nome: "Fulano"}
f = new Proxy (f, {
set: (target, prop) => {
if (prop === "nome") {
alert('Nome alterado')
}
}
})
$('#edita').click(() => {
f.nome = $('input').val()
console.log(f.nome)
})
HTML
<input type="text">
<button id="edita">EDITAR NOME</button>
After changing the name in the event, the console.log still displays Fulano
It worked, thank you.
– Felipe Coelho