{"id":25490190,"url":"https://github.com/fix2015/structure_stack","last_synced_at":"2025-11-08T12:30:35.284Z","repository":{"id":273065845,"uuid":"918609705","full_name":"fix2015/structure_stack","owner":"fix2015","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-18T12:03:02.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T12:30:40.539Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fix2015.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-18T11:44:08.000Z","updated_at":"2025-01-18T12:03:04.000Z","dependencies_parsed_at":"2025-01-18T12:40:52.427Z","dependency_job_id":null,"html_url":"https://github.com/fix2015/structure_stack","commit_stats":null,"previous_names":["fix2015/structure_stack"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_stack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_stack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_stack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fix2015%2Fstructure_stack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fix2015","download_url":"https://codeload.github.com/fix2015/structure_stack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239552865,"owners_count":19658003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-18T21:27:28.210Z","updated_at":"2025-11-08T12:30:35.221Z","avatar_url":"https://github.com/fix2015.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stack Data Structure in JavaScript 🚀  \n\nA simple implementation of the **Stack** data structure in JavaScript. This repository demonstrates how to create a stack class with essential methods and explains its functionality with practical examples.  \n\n---\n\n## What is a Stack?  \nA **Stack** is a data structure that follows the **LIFO** (Last In, First Out) principle. The last element added to the stack is the first one to be removed. Think of it as a stack of plates: you take the top plate first when serving.  \n\n---\n\n## Features  \n- **Push**: Add an item to the stack.  \n- **Pop**: Remove and return the top item.  \n- **Peek**: View the top item without removing it.  \n- **isEmpty**: Check if the stack is empty.  \n- **Size**: Get the number of items in the stack.  \n\n---\n\n## Code Implementation  \n\nHere’s the JavaScript implementation of the stack:  \n\n```javascript\nclass Stack {\n    constructor() {\n        this.items = []; // Initialize an empty array\n    }\n\n    // Add an item to the stack\n    push(element) {\n        this.items.push(element);\n    }\n\n    // Remove and return the top item\n    pop() {\n        if (this.isEmpty()) {\n            return \"Stack is empty!\";\n        }\n        return this.items.pop();\n    }\n\n    // Check if the stack is empty\n    isEmpty() {\n        return this.items.length === 0;\n    }\n\n    // Peek at the top item without removing it\n    peek() {\n        if (this.isEmpty()) {\n            return \"Stack is empty!\";\n        }\n        return this.items[this.items.length - 1];\n    }\n\n    // Get the size of the stack\n    size() {\n        return this.items.length;\n    }\n}\n```\n\n---\n\n## Example Usage  \n\n```javascript\n// Initialize the stack\nconst stack = new Stack();\n\n// Add items to the stack\nstack.push(\"Plate 1\");\nstack.push(\"Plate 2\");\nstack.push(\"Plate 3\");\n\n// Peek at the top item\nconsole.log(stack.peek()); // Output: Plate 3\n\n// Remove items from the stack\nconsole.log(stack.pop()); // Output: Plate 3\nconsole.log(stack.pop()); // Output: Plate 2\n\n// Check if the stack is empty\nconsole.log(stack.isEmpty()); // Output: false\n\n// Get the size of the stack\nconsole.log(stack.size()); // Output: 1\n```\n\n---\n\n## Real-World Applications  \n1. **Undo/Redo Operations**: In text editors and IDEs.  \n2. **Backtracking**: In algorithms like depth-first search (DFS).  \n3. **Expression Evaluation**: Managing operands and operators in mathematical expressions.  \n4. **Function Call Stack**: Handling nested function calls in programming.  \n\n---\n\n## TikTok Tutorial 🎥  \nWant to see a quick tutorial on how to build this? Check out this TikTok video:  \n[https://www.tiktok.com/@jsmentoring/video/7461022091421273376](https://www.tiktok.com/@jsmentoring/video/7461022091421273376)  \n\n---\n\n## How to Run the Code  \n1. Clone the repository:  \n   ```bash\n   git clone https://github.com/your-username/stack-data-structure.git\n   cd stack-data-structure\n   ```\n2. Open the file `stack.js` in your favorite code editor.  \n3. Run the file using Node.js:  \n   ```bash\n   node stack.js\n   ```\n\n---\n\n## Contributing  \nContributions are welcome! If you have suggestions or want to add new features, feel free to create a pull request.  \n\n---\n\n## License  \nThis project is licensed under the MIT License.  \n\n---\n\n## Connect with Me:\n- [LinkedIn - Vitalii Semianchuk](https://www.linkedin.com/in/vitalii-semianchuk-9812a786/)\n- [Telegram - @jsmentorfree](https://t.me/jsmentorfree) - We do a lot of free teaching on this channel! Join us to learn and grow in web development.\n- [Tiktok - @jsmentoring](https://www.tiktok.com/@jsmentoring) Everyday new videos\n- [Youtube - @jsmentor-uk](https://www.youtube.com/@jsmentor-uk) Mentor live streams\n- [Dev.to - fix2015](https://dev.to/fix2015) Javascript featured, live, experience\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffix2015%2Fstructure_stack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffix2015%2Fstructure_stack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffix2015%2Fstructure_stack/lists"}