const newList = [1, 2, 3, 4, 5]
const list = [4, 5, 6, 7, 8]
const endIndex = newList.findIndex(item => item === list[0]) // -> 3
const diff = newList.slice(0, endIndex === -1 ? undefined : endIndex)
console.log([...diff, ...list]) // -> [1, 2, 3, 4, 5, 6, 7, 8]
-
-
Save og24715/2e701d22a104b38312d161e913844602 to your computer and use it in GitHub Desktop.
Twitter で新しくツイートを取得する時に重複なしにがっちゃんこする
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment