svuotare un oggetto impostandolo su null





https://www.w3schools.com/js/tryit.asp?filename=tryjs_datatypes_null


<!DOCTYPE html>
<html>
<body>

<h2>JavaScript</h2>

<p>Objects can be emptied by setting the value to <b>null</b>.</p>

<p id="demo"></p>

<script>
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
person = null;
document.getElementById("demo").innerHTML = typeof person;
</script>

</body>
</html>




' oppure

https://www.w3schools.com/js/tryit.asp?filename=tryjs_datatypes_undefined_1


<!DOCTYPE html>
<html>
<body>

<h2>JavaScript</h2>

<p>Objects can be emptied by setting the value to <b>undefined</b>.</p>

<p id="demo"></p>

<script>
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
person = undefined;
document.getElementById("demo").innerHTML = person;
</script>

</body>
</html>










( svuotareunoggettoimpostandolosunull.html )- by Paolo Puglisi - Modifica del 17/12/2023