
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
babel-plugin-transform-es2015-arrow-functions
Advanced tools
Compile ES2015 arrow functions to ES5
In
var a = () => {};
var a = (b) => b;
const double = [1,2,3].map((num) => num * 2);
console.log(double); // [2,4,6]
var bob = {
_name: "Bob",
_friends: ["Sally", "Tom"],
printFriends() {
this._friends.forEach(f =>
console.log(this._name + " knows " + f));
}
};
console.log(bob.printFriends());
Out
var a = function a() {};
var a = function a(b) {
return b;
};
var double = [1, 2, 3].map(function (num) {
return num * 2;
});
console.log(double); // [2,4,6]
var bob = {
_name: "Bob",
_friends: ["Sally", "Tom"],
printFriends: function printFriends() {
var _this = this;
this._friends.forEach(function (f) {
return console.log(_this._name + " knows " + f);
});
}
};
console.log(bob.printFriends());
npm install --save-dev babel-plugin-transform-es2015-arrow-functions
.babelrc (Recommended).babelrc
// without options
{
"plugins": ["transform-es2015-arrow-functions"]
}
// with options
{
"plugins": [
["transform-es2015-arrow-functions", { "spec": true }]
]
}
babel --plugins transform-es2015-arrow-functions script.js
require("babel-core").transform("code", {
plugins: ["transform-es2015-arrow-functions"]
});
spec - This option wraps the generated function in .bind(this) and keeps uses of this inside the function as-is, instead of using a renamed this. It also adds a runtime check to ensure the functions are not instantiated.This plugin transforms ES2015 function names to ensure compatibility with older environments. While it focuses on function names rather than arrow functions, it serves a similar purpose of making ES2015 features compatible with ES5.
This plugin transforms ES2015 parameter features like default parameters and rest parameters into ES5-compatible code. It complements babel-plugin-transform-es2015-arrow-functions by handling other ES2015 syntax features.
This plugin transforms ES2015 template literals into ES5 string concatenations. Like babel-plugin-transform-es2015-arrow-functions, it ensures that modern JavaScript syntax can run in older environments.
FAQs
Compile ES2015 arrow functions to ES5
The npm package babel-plugin-transform-es2015-arrow-functions receives a total of 1,219,905 weekly downloads. As such, babel-plugin-transform-es2015-arrow-functions popularity was classified as popular.
We found that babel-plugin-transform-es2015-arrow-functions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.