$ cnpm install @putout/plugin-convert-for-in-to-for-of
The
for...instatement iterates over all enumerable properties of an object that are keyed by strings.The
for...ofstatement creates a loop which invokes a custom iteration hook with statements to be executed for the value of each element of an array.(c) MDN
????Putout plugin adds ability to convert for...in to for...of loop. Merged to @putout/plugin-for-of.
npm i @putout/plugin-convert-for-in-to-for-of -D
{
"rules": {
"convert-for-in-to-for-of/positive": "on",
"convert-for-in-to-for-of/negative": "on"
}
}
for (const item in object) {
if (object.hasOwnProperty(item)) {
log(item);
}
}
for (const item in object) {
if (!object.hasOwnProperty(item))
continue;
log(item);
}
for (const item of Object.keys(object)) {
log(item);
}
MIT
Copyright 2013 - present © cnpmjs.org | Home |