Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including babel-plugin-transform-undefined-to-void with all npm packages installed. Try it out:

var babelPluginTransformUndefinedToVoid = require("babel-plugin-transform-undefined-to-void")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

babel-plugin-transform-undefined-to-void v6.9.4

Replace references to `undefined` with `void 0`


Some JavaScript implementations allow undefined to be overwritten, this may lead to peculiar bugs that are extremely hard to track down.

This plugin transforms undefined into void 0 which returns undefined regardless of if it's been reassigned.



foo === undefined;


foo === void 0;


npm install babel-plugin-transform-undefined-to-void --save-dev


Via .babelrc (Recommended)


  "plugins": ["transform-undefined-to-void"]


babel --plugins transform-undefined-to-void script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["transform-undefined-to-void"]
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free