pop in javascript remove last value from array

     The pop() method removes the last element from an array and returns that element.

     pop() is intentionally generic; this method can be called or applied to objects resembling arrays. Objects which do not contain a length property reflecting the last in a series of consecutive, zero-based numerical properties may not behave in any meaningful manner.

If you call pop() on an empty array, it returns undefined.

Syntax

     Array.pop();

Example

     var ar=["1st","2nd","3rd","4th"];
     ar.pop()


Example Program:- (Editor)


Editor is Loading...

Advertisement

0 nhận xét:

Đăng nhận xét