Home > front end >  Modify the code style after the query output error reasons
Modify the code style after the query output error reasons

Time:03-26

Internet to Array. The forEach () and Array. The map () two pieces of code, and then I according to the Array. The style of the map () changes the Array. The forEach () code, specific as follows, but running will be displayed undefined, want to ask why can't modify





<body>

Call a function for each element, & lt;/p>



<script>
Var numbers1=[45, 4, 9, 16, 25];
Var numbers2=numbers1. ForEach (myFunction);

Document. The getElementById (" demo "). The innerHTML=numbers2;

The function myFunction (value) {
The return value.
}
</script>

CodePudding user response:

Array. The forEach not return a value, the sample of the forEach callback function is to modify the value of the global variable TXT, you didn't

  • Related