Skip to content

Latest commit

 

History

History
67 lines (54 loc) · 1.5 KB

File metadata and controls

67 lines (54 loc) · 1.5 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
pop Method (Array) (JavaScript) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
pop
JavaScript
TypeScript
DHTML
Pop method
4fae7f98-29f1-4041-ba43-601f2e5145ec
14
mikejo5000
mikejo
ghogen

pop Method (Array) (JavaScript)

Removes the last element from an array and returns it.

Syntax

  
arrayObj.pop( )  

Remarks

The push and pop methods enable you to simulate a stack, which uses the principle of last in, first out (LIFO) to store data.

The required arrayObj reference is an Array object.

If the array is empty, undefined is returned.

Example

The following example illustrates the use of the pop method.

var number;  
var my_array = new Array();  
  
my_array.push (5, 6, 7);  
my_array.push (8, 9);  
  
number = my_array.pop();  
while (number != undefined)  
   {  
   document.write (number + " ");  
   number = my_array.pop();  
   }  
  
// Output: 9 8 7 6 5  

Requirements

[!INCLUDEjsv55]

See Also

push Method (Array)