<button onclick="removeLastElement()">Remove Last Element</button>
<p id="demo"></p>
<script>
var courses = ["javascript", "php", "angularjs", "node js","Abc"];
document.getElementById("demo").innerHTML = courses;
function removeLastElement() {
var removed_element = courses.pop();
console.log(removed_element);
document.getElementById("demo").innerHTML = courses;
}
</script>
pop() returns removed element.