Change Missing From Changelog: forEach() Loop's `Return` returns to forEach()'s invocation point, not to the calling function.
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 11.8k
- Fork
- 7.9k
- Merge medio
- 1g 11h
- PR unite (30g)
- 11
Descrizione
Hey all,
I'm noticing that in upgrading to ReactJS Version 16.12.0 from 16.7.0, the behavior of foreach was changed, so that return returns to where foreach is called, and not the function calling the function containing the foreach. But I don't see this change here:
https://github.com/facebook/react/blob/master/CHANGELOG.md
Basically,
function1() {
function2();
console.log("function 1");
}
function2() {
const arr = ['cool'];
arr.forEach((var) => {
return var;
});
console.log("function 2");
}
Before 16.12.0, console output was: "function 1", but now it is "function 2; function 1." This change appears to be against MDN documentation and internet consensus: https://stackoverflow.com/questions/34653612/what-does-return-keyword-mean-inside-foreach-function
But it should have been included in the changelog, though I am not seeing it. Let me know if I'm misunderstanding.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da CHANGELOG.md e dalla voce del changelog di React 16.12.0 a cui fa riferimento l’issue. Verifica il comportamento segnalato di forEach() in base ai riferimenti collegati di MDN e Stack Overflow, quindi determina se nel changelog manca una voce; l’attività è completata quando il report è convalidato e il changelog riflette correttamente la release, se appropriato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, react
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100