The delete Operator
RUN
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <h1>Học lập trình miễn phí tại freetuts.net</h1> <p id="result"></p> <button onclick="myFunction()">Run</button> <script> var car = { name: "Lamborghini galardo", color: "black", cost: 300000, country: "Italy" } var content = 'name - ' + car.name + '<br>'; content = content + 'color - ' + car.color + '<br>'; content = content + 'cost - ' + car.cost + ' $ <br>'; content = content + 'country - ' + car.country + '<br>'; document.getElementById("result").innerHTML = content; function myFunction() { delete car.country; var content = 'name - ' + car.name + '<br>'; content = content + 'color - ' + car.color + '<br>'; content = content + 'cost - ' + car.cost + ' $ <br>'; content = content + 'country - ' + car.country + '<br>'; document.getElementById("result").innerHTML = content; }; </script> </body> </html>
PHÓNG TO