Best way to keep an ordered list of windows (from most-recently created to oldest)?

StackOverflow https://stackoverflow.com/questions/19970

  •  09-06-2019
  •  | 
  •  

Question

What is the best way to manage a list of windows (keeping them in order) to be able to promote the next window to the top-level when the current top-level window is closed.
This is for a web application, so we're using jQuery Javascript.

We'd talked through a few simplistic solutions, such as using an array and just treating [0] index as the top-most window.

I'm wondering if there's any potentially more efficient or useful alternative to what we had brainstormed.

Was it helpful?

Solution

A stack if you want to just close the window on top. A queue if you also need to open windows at the end.

OTHER TIPS

I don't really know javascript, but couldn't you create a stack of windows?

Stack/queue in JS is a simple array, which can be manipulated with .push(val), .pop(), .shift(val) and .unshift().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top