当前位置:网站首页>JS convert string to array object
JS convert string to array object
2022-06-12 12:23:00 【Cherry*】
The first way to write it
let str = "1,2,3"
let arr = str.split(",").map((item)=>{
for(let i = 0;i<str.length;i++){
let obj = {
};
obj.name = item;
return obj
}
})
console.log(arr)
The results are as follows :
The second way
let str = "1,2,3";
let arr = str.split(",");
for(let i = 0;i<arr.length;i++){
arr[i] = {
name1: arr[i]};
}
console.log(arr)
The results are as follows :
边栏推荐
- 用vector保存对象时保存指针的优点, 以及reserve的使用
- promise的理解已经利用promise实现图片的预加载(顺序加载)
- BAT面试&高级进阶,文末领取面试资料
- Dom and BOM in JS
- 获取本机所有ipv4, ipv6地址
- Pseudo instruction of arm instruction set
- Reprint --win10 open the task manager to solve the blue screen problem
- Tron API wave field transfer query interface PHP version package based on thinkphp5 attached interface document 20220528 version
- object. Defineproperty basic usage
- Win7 registers out of process components, services, and COM component debugging
猜你喜欢

无重复字符的最长字符串(LeetCode 3)

NDT registration principle

VGG小卷积代替大卷积 VS 深度可分离卷积

MySQL review

Matlab install license manager error -8

You can't just use console Log ()?

promise的理解已经利用promise实现图片的预加载(顺序加载)

轻量化---Project

LeetCode 890. Find and replace mode (analog + double hash table)

Take the web page animation effects that can be used. Don't you come and have a look?
随机推荐
Take the web page animation effects that can be used. Don't you come and have a look?
传统的DOM渲染方式?
TRON-api-波场转账查询接口-PHP版本-基于ThinkPHP5封装-附带接口文档-20220602版本-接口部署好适用于任何开发语言
Promise understanding has used promise to realize picture preloading (sequential loading)
The advantages of saving pointers when saving objects with vector and the use of reserve
【Leetcode】637. Layer average of binary tree
Dom and BOM in JS
Cocktail sort
sublime_text使用
Load/store memory access instruction of arm instruction set (1)
Open source project - (erp+ Hotel + e-commerce) background management system
关于报文
AutoLock 解决加锁后忘记解锁问题
Create servlet project
Win7 registers out of process components, services, and COM component debugging
Beyondcompare 4 uses PJ
for in 与Object.keys()的区别
树的前序,中序,后序遍历
Load/store instruction addressing mode of arm instruction set (2)
[translation] go references - the go memory model | memory model for Chinese translation of official golang documents