阵列处理问题

问题描述 投票:0回答:1

我需要帮助:)

我正在尝试获得这样的数组:

['XSRF-TOKEN=advlqegqeozvqqeax; Max-Age=259200; Expires=Mon, 09-jul-2011 22:28:41 GMT; Path=/',
  'JWT-SESSION=qefqefoizxivhiohqdiovhoiqeioghqehoghioqe; Max-Age=259200; Expires=Wed, 13-jul-2011 22:28:41 GMT; Path=/; HttpOnly' ]

并以这种方式放置:

XSRF-TOKEN=advlqegqeozvqqeax; JWT-SESSION=qefqefoizxivhiohqdiovhoiqeioghqehoghioqe;

但是我是NodeJS的新手,我正在尝试学习,

你们能帮我吗?我被困了很长时间:(

非常感谢

node.js
1个回答
1
投票

您可以编写类似的内容:

const array = [
'XSRF-TOKEN=advlqegqeozvqqeax; Max-Age=259200; Expires=Mon, 09-jul-2011 22:28:41 GMT; Path=/', 
'JWT-SESSION=qefqefoizxivhiohqdiovhoiqeioghqehoghioqe; Max-Age=259200; Expires=Wed, 13-jul-2011 22:28:41 GMT; Path=/; HttpOnly' 
]

const result = array.map( properties => properties.split(';')[0] ).join(';')

console.log(result);

这里是我使用的功能:

© www.soinside.com 2019 - 2024. All rights reserved.