Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

removing the first match in array

//removing the first match of 5 from [2,5,9,1,5,8,5])
function removeItemOnce(arr, value) {
  var index = arr.indexOf(value);
  if (index > -1) {
    arr.splice(index, 1);
  }
  return arr;
}

// Usage
console.log(removeItemOnce([2,5,9,1,5,8,5], 5))
Comment

PREVIOUS NEXT
Code Example
Javascript :: Passing arrays to functions with the spread operator 
Javascript :: vue compositon api reusable code reuse code 
Javascript :: converting JSON to jsObject 
Javascript :: Will Yield function Model 
Javascript :: javascript asynchronous 
Javascript :: Return object in parenthesis to avoid it being considered a wrapping function body 
Javascript :: string inverter vs property binding in angular 
Javascript :: javascript one linde condition 
Javascript :: allow only numbers in textbox javascript onkeypress 
Javascript :: javascript get css property 
Javascript :: react axios project importing online same products with table from fake API 
Javascript :: netsuite get search column value suitescript 
Javascript :: apollo client multiple endpoints 
Javascript :: reverse 
Javascript :: JS function examples 
Javascript :: regex remove whitespace 
Javascript :: google apps script parse html 
Javascript :: NodeJS Multi-Core Processors Example 
Javascript :: ajax fail function parameters 
Javascript :: how to add header to axios request 
Javascript :: replace methord 
Javascript :: delete file firebase angular 
Javascript :: nodejs version abfragen 
Javascript :: TypeError: Invalid schema configuration: `True` is not a valid type at path `id.required`. See https://bit.ly/mongoose-schematypes for a list of valid schema types.] 
Javascript :: how to render array buffer binary audio js 
Javascript :: html5 javascript json vertical colom grap 
Javascript :: angular universal prerender 
Javascript :: how to setup a webpack quickly 
Javascript :: AngularJS get ETag header from $http.put request 
Javascript :: Get value from each *ngFor ionic 4, ionic 5, ionic 6 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =