Use of PUSH and POP in javascript?

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOps School!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

PUSH and POP is used to perform insertions as well as deletions from the object. array_push is used to add value in the array(it always add new value at the last place) and array_pop is used to remove last value from the array.

POP() syntax

array.pop()

PUSH() syntax

array.push(item1, item2, ..., itemX)

example

<!DOCTYPE html>
<html>
<head>
		<title> alert in javascript</title>
</head>
<body>
		<script>
		var array = ["sam","ramu","array","string","function"];
		
		document.write(array + "<br><br>");
		
		array.pop("function");
		
		document.write(array + "<br><br>");
		
		array.push("salman");
		
		document.write(array + "<br><br>");
		
		</script>

</body>
</html>

output

sam,ramu,array,string,function

sam,ramu,array,string

sam,ramu,array,string,salman

Related Posts

Master Real-World CI/CD: Why Expert Guidance Beats Tutorials

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

Bootcamp vs Self-Paced Learning: Which Is Better for DevOps?

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

The UK Live Scene Playbook: How Modern Ticketing Works, What It Costs, and How to Find the Best Nights Out

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

Team Mentoring with an Instructor: How to Build High-Performing Engineering Teams

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

Behind the Velvet Rope: What It Really Takes to Run and Attend Events in Japan

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More

A Practical Guide to Reaching the Right Attendees and Keeping Them Engaged

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps! We spend hours scrolling social media and waste money on things we forget, but won’t spend 30…

Read More
guest

0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x