当前位置:网站首页>js對JSON數組的增删改查
js對JSON數組的增删改查
2022-07-06 23:14:00 【~疆】
目錄
查詢記錄。根據username查詢記錄

const users = [
{ username: "張三", password: 333 },
{ username: "李四", password: 444 },
{ username: "王五", password: 555 },
];
//查詢記錄。根據username查詢記錄
let data = users.filter((item) => item.username == "張三");
console.log("根據username查詢出的記錄:", data);删除記錄。根據username删除記錄

const users = [
{ username: "張三", password: 333 },
{ username: "李四", password: 444 },
{ username: "王五", password: 555 },
];
//删除記錄。根據username删除記錄
let data = users.filter((item) => item.username == "張三");
console.log("根據username查詢出的記錄:", data);
let index = users.indexOf(data[0]);
console.log("索引index:", index);
index !== -1 && users.splice(index, 1);
console.log("删除一條記錄後的users:", users);修改記錄。根據username修改password

const users = [
{ username: "張三", password: 333 },
{ username: "李四", password: 444 },
{ username: "王五", password: 555 },
];
//修改記錄。根據username修改password
let data = users.filter((item) => item.username == "張三");
console.log("根據username查詢出的記錄:", data);
data[0].password = 3333;
console.log("修改一條記錄後的users:", users);新增記錄。

const users = [
{ username: "張三", password: 333 },
{ username: "李四", password: 444 },
{ username: "王五", password: 555 },
];
//新增記錄。
users.push({ username: "趙六", password: 666 });
console.log("新增一條記錄後的users:", users);边栏推荐
- 企业不想换掉用了十年的老系统
- 「小程序容器技术」,是噱头还是新风口?
- Station B Big utilise mon monde pour faire un réseau neuronal convolutif, Le Cun Forward! Le foie a explosé pendant 6 mois, et un million de fois.
- 石墨文档:4大对策解决企业文件信息安全问题
- The application of machine learning in software testing
- Jafka source analysis processor
- (shuttle) navigation return interception: willpopscope
- Slide the uniapp to a certain height and fix an element to the top effect demo (organize)
- Custom swap function
- How to choose indoor LED display? These five considerations must be taken into account
猜你喜欢

B站大佬用我的世界搞出卷积神经网络,LeCun转发!爆肝6个月,播放破百万

B站大佬用我的世界搞出卷積神經網絡,LeCun轉發!爆肝6個月,播放破百萬

On the problems of born charge and non analytical correction in phonon and heat transport calculations

Efficient ETL Testing

With the help of this treasure artifact, I became the whole stack

Case recommendation: An Qing works with partners to ensure that the "smart court" is more efficient

欧洲生物信息研究所2021亮点报告发布:采用AlphaFold已预测出近1百万个蛋白质

Use mitmproxy to cache 360 degree panoramic web pages offline

MATLAB小技巧(27)灰色预测

Gpt-3 is a peer review online when it has been submitted for its own research
随机推荐
Is the more additives in food, the less safe it is?
OpenSSL:适用TLS与SSL协议的全功能工具包,通用加密库
使用MitmProxy离线缓存360度全景网页
MySQL authentication bypass vulnerability (cve-2012-2122)
With the help of this treasure artifact, I became the whole stack
[step on pit collection] attempting to deserialize object on CUDA device+buff/cache occupy too much +pad_ sequence
Improving Multimodal Accuracy Through Modality Pre-training and Attention
Detailed explanation of ThreadLocal
memcached
Cloud native technology container knowledge points
Rust knowledge mind map XMIND
On the problems of born charge and non analytical correction in phonon and heat transport calculations
Custom swap function
DR-Net: dual-rotation network with feature map enhancement for medical image segmentation
案例推荐丨安擎携手伙伴,保障“智慧法院”更加高效
three. JS gorgeous bubble effect
OpenSSL: a full-featured toolkit for TLS and SSL protocols, and a general encryption library
Modules that can be used by both the electron main process and the rendering process
#DAYU200体验官# 首页aito视频&Canvas绘制仪表盘(ets)
(shuttle) navigation return interception: willpopscope