在javascript中重命名对象键(变量)
我有一个对象,其中包含名为 [0...10] 的变量和几个具有正常名称的变量。我用delete obj[3]删除其中之一。然后这个序列中有一个间隙。我现在想从 [0...10] 开始排列它们。我的第一个想法是循环并重命名键(变量)。我怎样才能做到呢?
PS - 对象无法更改其结构或转换为数组以使用 splice()..
I am having an object with variables named [0...10] and few variables with normal names. I delete one of them with delete obj[3]. Then there is a gap in this sequence. I want to arrange them now from [0...10]. My first though is to loop through and rename keys(variables). How I can do it?
P.S. - Object cannot change its structure or be converted to an array to use splice()..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么你为什么不尝试一下你的第一个想法呢?
So why haven't you tried your first thought?