If they are planning to interview you specifically on JAVA, it guarantees questions about OOP. I will list a number of very common questions asked in JAVA interviews: It could be about garbage collection:
Home/arrays
WikiQuora Latest Questions
How do I remove a specific value from an array? Something like: array.remove(value); Constraints: I have to use core JavaScript. Frameworks are not allowed.
Find the index of the array element you want to remove using indexOf, and then remove that index with splice. The splice() method changes the contents of an array by removing existing elements and/or adding new elements. const array = [2, 5, 9]; console.log(array); const index = array.indexOf(5); ifRead more
Find the
index
of the array element you want to remove usingindexOf
, and then remove that index withsplice
.The second parameter of
splice
is the number of elements to remove. Note thatsplice
modifies the array in place and returns a new array containing the elements that have been removed.For completeness, here are functions. The first function removes only a single occurrence (e.g., removing the first match of
5
from[2,5,9,1,5,8,5]
), while the second function removes all occurrences:In TypeScript, these functions can stay type-safe with a type parameter:
See less