Skip to content

Commit cdf9754

Browse files
authored
Replace .map() with .forEach() in JavaScript (#1347)
The code is not mapping the data to a new array. It was being used for iteration only. Therefore, forEach() is the more appropriate function which does not build a new Array.
1 parent c543358 commit cdf9754

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

debug_toolbar/static/debug_toolbar/js/toolbar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const djdt = {
147147

148148
ajax(ajax_data.url, ajax_data).then(function(data) {
149149
djDebug.setAttribute('data-store-id', newStoreId);
150-
Object.keys(data).map(function (panelId) {
150+
Object.keys(data).forEach(function (panelId) {
151151
if (djDebug.querySelector('#'+panelId)) {
152152
djDebug.querySelector('#'+panelId).outerHTML = data[panelId].content;
153153
djDebug.querySelector('#djdt-'+panelId).outerHTML = data[panelId].button;
@@ -172,7 +172,7 @@ const djdt = {
172172

173173
ajax(ajax_data.url, ajax_data).then(function(data) {
174174
if (data.requests.constructor === Array) {
175-
data.requests.map(function(request) {
175+
data.requests.forEach(function(request) {
176176
if (!container.querySelector('[data-store-id="'+request.id+'"]')) {
177177
container.innerHTML = request.content + container.innerHTML;
178178
}

0 commit comments

Comments
 (0)