Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

@realestate_Kino

LIFO(後入れ先出法)

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
0
Help us understand the problem. What are the problem?