Home>
I want to delete the first character with
.map ().
Error messageThe result is as follows on the console.
[undefined, undefined]
Applicable source code
var arr = ['0a', '0b']
var result = arr.map (function (e) {e.slice (1)});
console.log ('result', result);
The following were confirmed.
// Check that the first character has been deleted
str = '0a';
var a = str.slice (1);
console.log ('a', a);
// Confirm that "0a" and "0b" are passed to "e"
var arr = ['0a', '0b']
var test = arr.map (function (e) {console.log ('e', e);});
The usage of slice is correct, and the character string to be deleted can be passed as "e". Why does the above problem occur? Can someone tell me?
-
Answer # 1
-
Answer # 2
Return or use arrows
var result = arr.map (function (e) {return e.slice (1);}); Or var result = arr.map (e =>e.slice (1));
-
Answer # 3
return.
var result = arr.map (function (e) {e.slice (1)});
Related articles
- it's the second day of programming for the first time tell us about javascript
- javascript - i want to separate my name by surname and first name
- i want to delete the character string of the csv file with the character string in the txt file in the batch file
- javascript - i want to make random numbers into character strings (i want to implement using only html and javasrict)
- javascript - body cannot be sent during axios delete method
- javascript - extract the character string sandwiched between specific character strings
- all javascript is executed first
- javascript - i want to add the first character to the end
- ios - i want to make the first character of the search bar small
- javascript - i want to delete the half-width space that occurs at the time of line break in vuejs
- [javascript] i want to copy the character string embedded in html to the clipboard
- javascript - how to make a character that is an entity reference into an emoji
- javascript - i want to repeat extraction for a character string and convert it to a regular expression
- javascript - delete the data in the specified row
- javascript - i want to delete in real time with real-time chat using pusher, but i can not implement it laravel,vuejs
- javascript - js find character acquisition
- php - i want to delete a character string that precedes a specific character (appears multiple times)
- javascript - how to delete the item of json array read by nodejs?
- c ++ - i want to know why the fscanf_s ();function can only set the first character
- javascript - i want to update the id when the delete button is pressed in the todo list
Related questions
- javascript : Show button only after div click
- javascript : Validation of one email or phone input at a time
- javascript : Jquery UI -Slider Call
- javascript : [Animation that scrolls "fluffy" when scrolling] cannot be implemented
- javascript : Select2 | Hide selected items when exceeding a certain amount
- javascript : why doesn't the toFixed (2) function work in a promise? JS works separately
- javascript : (AJAX + PHP) Why is sending a POST request not processed by clicking on the Delete button?
- javascript : How to use JS to download images in an article using a button that appears on hover
- javascript : Create picture from blocks
- javascript : Output to page from $ .getJson
Did not return. It was confused with the arrow function.