CINXE.COM
<!doctype html><html lang=en dir=ltr class="plugin-pages plugin-id-default" data-has-hydrated=false><meta charset=UTF-8><meta name=generator content="Docusaurus v3.7.0"><title data-rh=true>Babel 路 Babel</title><meta data-rh=true name=viewport content="width=device-width, initial-scale=1.0"><meta data-rh=true name=twitter:card content=summary_large_image><meta data-rh=true property=og:url content=https://babeljs.io/><meta data-rh=true property=og:locale content=en><meta data-rh=true name=docusaurus_locale content=en><meta data-rh=true name=docusaurus_tag content=default><meta data-rh=true name=docsearch:language content=en><meta data-rh=true name=docsearch:docusaurus_tag content=default><meta data-rh=true property=og:title content="Babel 路 Babel"><meta data-rh=true name=description content="The compiler for next generation JavaScript"><meta data-rh=true property=og:description content="The compiler for next generation JavaScript"><link data-rh=true rel=icon href=/img/favicon.png><link data-rh=true rel=canonical href=https://babeljs.io/><link data-rh=true rel=alternate href=https://babeljs.io/ hreflang=en><link data-rh=true rel=alternate href=https://babeljs.io/ hreflang=x-default><link data-rh=true rel=preconnect href=https://M7KGJDK6WF-dsn.algolia.net crossorigin=anonymous><script data-rh=true>document.addEventListener("DOMContentLoaded",function(){void 0===window.docusaurus&&insertBanner()});function insertBanner(){var n=document.createElement("div");n.id="__docusaurus-base-url-issue-banner-container",n.innerHTML='\n<div id="__docusaurus-base-url-issue-banner" style="border: thick solid red; background-color: rgb(255, 230, 179); margin: 20px; padding: 20px; font-size: 20px;">\n <p style="font-weight: bold; font-size: 30px;">Your Docusaurus site did not load properly.</p>\n <p>A very common reason is a wrong site <a href="https://docusaurus.io/docs/docusaurus.config.js/#baseUrl" style="font-weight: bold;">baseUrl configuration</a>.</p>\n <p>Current configured baseUrl = <span style="font-weight: bold; color: red;">/</span> (default value)</p>\n <p>We suggest trying baseUrl = <span id="__docusaurus-base-url-issue-banner-suggestion-container" style="font-weight: bold; color: green;"></span></p>\n</div>\n',document.body.prepend(n);var e=document.getElementById("__docusaurus-base-url-issue-banner-suggestion-container"),s=window.location.pathname,o="/"===s.substr(-1)?s:s+"/";e.innerHTML=o}</script><script data-rh=true src=https://unpkg.com/ace-builds@1.3.3/src-min-noconflict/ace.js defer></script><link rel=alternate type=application/rss+xml href=/blog/rss.xml title="Babel RSS Feed"><link rel=alternate type=application/atom+xml href=/blog/atom.xml title="Babel Atom Feed"><link rel=search type=application/opensearchdescription+xml title=Babel href=/opensearch.xml><script src=https://unpkg.com/@babel/standalone@^7.0.0/babel.min.js defer></script><script src=/js/components/mini-repl.js type=module></script><script src=/js/components/assumption-repl.js type=module></script><link rel=stylesheet href=/assets/css/styles.c1330e66.css><script src=/assets/js/runtime~main.64de2abd.js defer></script><script src=/assets/js/main.6f8595d5.js defer></script><body class=navigation-with-keyboard><script>!function(){var t,e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme")}catch(t){}}();t=null!==e?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":(window.matchMedia("(prefers-color-scheme: light)").matches,"light"),document.documentElement.setAttribute("data-theme",t)}(),function(){try{for(var[t,e]of new URLSearchParams(window.location.search).entries())if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id=__docusaurus><div role=region aria-label="Skip to main content"><a class=skipToContent_oPtH href=#__docusaurus_skipToContent_fallback>Skip to main content</a></div><nav aria-label=Main class="navbar navbar--fixed-top"><div class=navbar__inner><div class=navbar__items><button aria-label="Toggle navigation bar" aria-expanded=false class="navbar__toggle clean-btn" type=button><svg width=30 height=30 viewBox="0 0 30 30" aria-hidden=true><path stroke=currentColor stroke-linecap=round stroke-miterlimit=10 stroke-width=2 d="M4 7h22M4 15h22M4 23h22"/></svg></button><a class=navbar__brand href=/><div class=navbar__logo><img src=/img/babel.svg alt="Babel logo" class="themedComponent_siVc themedComponent--light_hHel"><img src=/img/babel.svg alt="Babel logo" class="themedComponent_siVc themedComponent--dark_yETr"></div></a></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href=/docs/>Docs</a><a class="navbar__item navbar__link" href=/setup>Setup</a><a href=/repl class="navbar__item navbar__link" target=_top>Try it out</a><a class="navbar__item navbar__link" href=/videos/>Videos</a><a class="navbar__item navbar__link" href=/blog>Blog</a><div class=navbarSearchContainer_bzqh><button type=button class="DocSearch DocSearch-Button" aria-label="Search (Command+K)"><span class=DocSearch-Button-Container><svg width=20 height=20 class=DocSearch-Search-Icon viewBox="0 0 20 20" aria-hidden=true><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke=currentColor fill=none fill-rule=evenodd stroke-linecap=round stroke-linejoin=round /></svg><span class=DocSearch-Button-Placeholder>Search</span></span><span class=DocSearch-Button-Keys></span></button></div><a href=https://opencollective.com/babel target=_blank rel="noopener noreferrer" class="navbar__item navbar__link">Donate<svg width=13.5 height=13.5 aria-hidden=true viewBox="0 0 24 24" class=iconExternalLink_nPrP><path fill=currentColor d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"/></svg></a><a class="navbar__item navbar__link" href=/team>Team</a><a href=https://github.com/babel/babel target=_blank rel="noopener noreferrer" class="navbar__item navbar__link">GitHub<svg width=13.5 height=13.5 aria-hidden=true viewBox="0 0 24 24" class=iconExternalLink_nPrP><path fill=currentColor d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"/></svg></a><div class="toggle_ki11 colorModeToggle_Hewu"><button class="clean-btn toggleButton_MMFG toggleButtonDisabled_Uw7m" type=button disabled title="Switch between dark and light mode (currently light mode)" aria-label="Switch between dark and light mode (currently light mode)" aria-live=polite aria-pressed=false><svg viewBox="0 0 24 24" width=24 height=24 class=lightToggleIcon_lgto><path fill=currentColor d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"/></svg><svg viewBox="0 0 24 24" width=24 height=24 class=darkToggleIcon_U96C><path fill=currentColor d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"/></svg></button></div></div></div><div role=presentation class=navbar-sidebar__backdrop></div></nav><div id=__docusaurus_skipToContent_fallback class="main-wrapper mainWrapper_MB5r"><div><div class=hero><a href="https://teespring.com/babel-christmas?pr=FLAVORTOWN" target=_blank rel="noopener noreferrer"><div class=homepage-banner>Get Babel Holiday Apparel 馃憰</div></a><div class=hero__container><h1>Babel is a JavaScript compiler.</h1><p>Use next generation JavaScript, today.<div class=hero__announcement><span><strong>Babel 7.27 is released!</strong> Please read our<!-- --> <a href=/blog/2025/03/24/7.27.0>blog post</a> for highlights and<!-- --> <a href=https://github.com/babel/babel/releases/tag/v7.27.0 target=_blank rel="noopener noreferrer">changelog</a> <!-- -->for more details!</span></div><div class=dummy-hero-repl></div><div class=hero-repl hidden><div class=hero-repl__editor><div class="hero-repl__pane hero-repl__pane--left"><h3>Put in next-gen JavaScript</h3><div id=hero-repl-in class=hero-repl__code></div></div><div class="hero-repl__pane hero-repl__pane--right"><h3>Get browser-compatible JavaScript out</h3><div id=hero-repl-out class=hero-repl__code></div><div class=hero-repl__error></div></div></div></div></div></div><div class=mainContainer style=padding:0><div style=padding-bottom:20px><div class=wrapper><div class=gridBlock><div class=blockElement style="font-size:18px;max-width:800px;padding:45px 0 7px;margin:0 auto"><p>Learn more about Babel with our<!-- --> <a href=/docs>getting started guide</a> or check out some<!-- --> <a href=/videos>videos</a> on the people and concepts behind it.</div></div></div></div><div class="container paddingBottom"><div class="wrapper productShowcaseSection"><h3>Current Sponsors</h3><p>We're a small group of <a href=/team>volunteers</a> that spend their free time maintaining this project, funded by the community. If Babel has benefited you in your work, becoming a<!-- --> <a href=https://github.com/babel/babel/blob/main/CONTRIBUTING.md target=_blank rel="noopener noreferrer">contributor</a> <!-- -->or <a href=https://opencollective.com/babel target=_blank rel="noopener noreferrer">sponsoring</a> might just be a great way to give back!<div class=sponsor-tiers id=sponsors><div><h3>Base Support</h3><div>are currently pledging or have donated an average of<!-- --> <!-- -->>$2000<!-- -->/month in the last year<!-- --> </div><br><ul class="sponsors-tier tier-base-support-sponsors"><li><a href=https://www.airbnb.com/ target=_blank rel="noopener sponsored" title=Airbnb><img src=https://images.opencollective.com/airbnb/d327d66/logo.png alt="Sponsored by Airbnb"></a><li><a href=https://handsontable.com target=_blank rel="noopener sponsored" title="Handsontable - JavaScript Data Grid"><img src=https://images.opencollective.com/handsontable-javascript-data-grid/84dc03e/logo.png alt="Sponsored by Handsontable - JavaScript Data Grid"></a><li><a href=https://www.igalia.com/ target=_blank rel="noopener sponsored" title=Igalia><img src=https://images.opencollective.com/igalia/1c2e7cb/logo.png alt="Sponsored by Igalia"></a></ul></div><div><h3>Gold</h3><div>are currently pledging or have donated an average of<!-- --> <!-- -->$1000-$2000<!-- -->/month in the last year<!-- --> </div><br><ul class="sponsors-tier tier-gold-sponsors"><li><a href=https://buyreviewz.com/buy-google-reviews target=_blank rel="noopener sponsored" title="Buy Google Reviews"><img src=https://images.opencollective.com/buy-google-reviews-usa/78797fd/logo.png alt="Sponsored by Buy Google Reviews"></a><li><a href=https://github.com/coinbase target=_blank rel="noopener sponsored" title=Coinbase><img src="https://avatars.githubusercontent.com/u/1885080?s=200&v=4" alt="Sponsored by Coinbase"></a><li><a href=https://developer.americanexpress.com/ target=_blank rel="noopener sponsored" title="American Express"><img src="https://avatars.githubusercontent.com/u/3853301?s=200&v=4" alt="Sponsored by American Express"></a></ul></div><div><h3>Silver</h3><div>are currently pledging or have donated an average of<!-- --> <!-- -->$500-$1000<!-- -->/month in the last year<!-- --> </div><br><ul class="sponsors-tier tier-silver-sponsors"><li><a href=https://codecademy.com target=_blank rel="noopener sponsored" title=Codecademy><img src=https://images.opencollective.com/codecademy/d56a48d/logo.png alt="Sponsored by Codecademy"></a><li><a href=https://www.turtlebet.com/fi/kaikki-nettikasinot.html target=_blank rel="noopener sponsored" title="Turtlebet - Nettikasinot"><img src=https://images.opencollective.com/turtlebet-nettikasinot/d4e220c/logo.png alt="Sponsored by Turtlebet - Nettikasinot"></a><li><a href=https://www.sanity.io/ target=_blank rel="noopener sponsored" title=Sanity><img src=https://images.opencollective.com/sanity_io/558f87f/logo.png alt="Sponsored by Sanity"></a><li><a href=https://www.nettikasinot.org target=_blank rel="noopener sponsored" title=Nettikasinot.org><img src=https://images.opencollective.com/nettikasinot-org/53a4b44/logo.png alt="Sponsored by Nettikasinot.org"></a><li><a href=https://mediamister.com/ target=_blank rel="noopener sponsored" title="Media Mister"><img src=https://images.opencollective.com/media-mister/908143d/logo.png alt="Sponsored by Media Mister"></a><li><a href=https://github.com/acv-auctions target=_blank rel="noopener sponsored" title="ACV Auctions"><img src="https://avatars.githubusercontent.com/u/9889795?s=200&v=4" alt="Sponsored by ACV Auctions"></a><li><a href=https://route4me.com/ target=_blank rel="noopener sponsored" title="Route Planner"><img src=https://github.com/user-attachments/assets/002949fe-aa5e-4311-b77f-7f2c905e91f5 alt="Sponsored by Route Planner"></a></ul></div></div></div></div></div></div></div><footer class=nav-footer id=footer><section class=sitemap><a class=nav-home href=/><img src=https://d33wubrfki0l68.cloudfront.net/7a197cfe44548cc1a3f581152af70a3051e11671/78df8/img/babel.svg alt=Babel width=66 height=58></a><div><h5>Docs</h5><a href=/docs/learn>Learn ES2015</a></div><div><h5>Community</h5><a href=/videos>Videos</a><a href=/users>User Showcase</a><a href=http://stackoverflow.com/questions/tagged/babeljs target=_blank rel="noopener noreferrer">Stack Overflow</a><a href=https://babeljs.slack.com/ target=_blank rel="noopener noreferrer">Slack Channel</a><a href=https://x.com/babeljs target=_blank rel="noopener noreferrer">X (Twitter)</a><a href=https://bsky.app/profile/babel.dev target=_blank rel="noopener noreferrer">Bluesky</a></div><div><h5>More</h5><a href=/blog>Blog</a><a href=https://github.com/babel target=_blank rel="noopener noreferrer">GitHub Org</a><a href=https://github.com/babel/babel target=_blank rel="noopener noreferrer">GitHub Repo</a><a href=https://github.com/babel/website target=_blank rel="noopener noreferrer">Website Repo</a><a href=https://old.babeljs.io target=_blank rel="noopener noreferrer">Old 6.x Site</a><a href=http://henryzoo.com/babel.github.io target=_blank rel="noopener noreferrer">Old 5.x Site</a></div></section></footer></div>