如何在javascript中选择未知数字?
例如我有:
array(2
,1
,3
,4
,5,
6
,7
)
和 我已经知道 (2
,1
,3
)
我应该如何得到 (4
,5
,6
, 7
)如果我知道从 1
到 7
存在所有数字,并且这些数字我已经知道
所以我想要一个包含我的数字的数组还不知道。
抱歉,如果听起来很愚蠢:|
So for example I have:
array(2
,1
,3
,4
,5
,6
,7
)
and I already know (2
,1
,3
)
How should I get (4
,5
,6
, 7
) if I know that all numbers exists from 1
to 7
and the numbers what I already know
So I want an array with the numbers what I don't know yet.
Sorry if sounds stupid :|
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 A =
(2, 1, 3) 且 B =
(1, 2, 3, 4, 5, 6, 7)
那么你想要不常见的元素 (即,两者都不存在的元素)?您可以尝试以下操作:
另请注意,如果您有:
A =
(2, 1, 3, 9)
且 B =(1, 2, 3, 4, 5, 6, 7 )
,您将得到(2, 1, 3, 9)
即在任一元素中都找不到的元素。If A =
(2, 1, 3)
and B =(1, 2, 3, 4, 5, 6, 7)
Then do you want the uncommon elements (i.e., elements not existing in either)? You can try this:
Also note that if you had:
A =
(2, 1, 3, 9)
and B =(1, 2, 3, 4, 5, 6, 7)
, you would get(2, 1, 3, 9)
i.e., elements not found in either one.