Help us understand the problem. What is going on with this article?

LIFO(後入れ先出法)

More than 3 years have passed since last update.

LIFOという後入れ先出し法(last in first out)
javascriptの配列要素の取り出し方法

最後の格納(push)したデータから取り出される方法

この方法を学ぶために
pop()=配列の最後の要素を取り出すメソッド
が重要になる

例🔻

var ary=['aa','bb','cc'];

ary.push('dd');
document.write('ary='+ ary + '<br>');  //ary=aa,bb,cc,dd

var pop1=ary.pop();
document.write('pop1=' + pop1 + '<br>'); //pop1=dd
document.write('ary=' + ary + '<br>');  //ary=aa,bb,cc

var pop2 = ary.pop();
document.write('pop2=' + pop2 + '<br>'); //cc
document.write('ary=' + ary + '<br>');  //aa,bb

ary.push('zz');
document.write('ary=' + ary + '<br>');   //aa,bb,zz

LIFOの使い方として、履歴の管理が代表的であるらしい。
戻るボタンをクリックすると、最後に追加された履歴のページから順に表示される方法が、LIFOのやり方で実現できるとの事。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした