I made this code to study the JavaScript Proxy. It works by detecting the object's property change but when I call the property in 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 click event of the button the console.log still displays So-and-so