peek Summary Returns the most recently added element without removing it. Usage public T+ peek() Returns The element at the top of the stack (most recently added element) or undefined if the stack was empty. Description Returns the most recently added element from the stack without removing it. If the stack is empty, undefined will be returned. Examples Basic Usage 12345import System; auto stack = new Stack<int>([ 1, 2 ]);Console.log(stack.peek()); // 2Console.log(stack.peek()); // 2 Share HTML | BBCode | Direct Link