The prompt
Refactor the following code to modern es6 programming standards:
[INSERT YOUR CODE HERE] What it is
Code Modernizer is a straightforward prompt for upgrading legacy JavaScript (or similar language) code to ES6 and later standards. When you paste in older code that uses var, function keywords, string concatenation, and callback patterns, the AI rewrites it using const/let, arrow functions, template literals, destructuring, spread operators, async/await, and other modern features.
This prompt is most useful for developers who inherit or maintain older codebases and want to bring them in line with current best practices without spending hours on manual refactoring. It is also a learning tool: by comparing the before and after, developers who are less familiar with ES6 can see exactly how each pattern translates.
The prompt is intentionally minimal -- it gives the AI freedom to apply whichever modern standards are appropriate. If you want more control, you can extend it by specifying which features to use or avoid, or by adding constraints about browser compatibility.
Who it's for
- Developers
- JavaScript developers maintaining legacy codebases
Requirements
Requirements
- Any AI chatbot (ChatGPT, Claude, Gemini)
برومبت يطلب من الذكاء الاصطناعي تحديث الكود القديم إلى معايير ES6 الحديثة مثل الدوال السهمية والتفكيك وقوالب النصوص.
Examples
From the source
PromptRefactor the following code to modern es6 programming standards:
[INSERT YOUR CODE HERE]Expected output: From PickleBoxer's dev-chatgpt-prompts collection on GitHub.
Pros & cons
Pros
- Pro:Quickly brings legacy code up to current standards without manual rewriting
- Pro:Helps developers learn modern syntax by seeing the transformation side by side
Cons
- Con:ES6 features like arrow functions change
thisbinding, which may introduce bugs if the AI does not account for the original context - Con:The prompt does not specify which ES6+ features to prioritize, so results may vary between models
Tips
- Paste complete functions or modules rather than isolated lines for better context
- Specify your target environment (Node.js version, browser support) if backward compatibility matters
- Ask the AI to explain each modernization change it makes so you learn the ES6 patterns