removeFromArray.js 437 B

1234567891011121314151617181920212223
  1. "use strict";
  2. /**
  3. * Copyright (c) 2013-present, Facebook, Inc.
  4. *
  5. * This source code is licensed under the MIT license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. *
  8. * @typechecks
  9. *
  10. */
  11. /**
  12. * Removes an element from an array.
  13. */
  14. function removeFromArray(array, element) {
  15. var index = array.indexOf(element);
  16. if (index !== -1) {
  17. array.splice(index, 1);
  18. }
  19. }
  20. module.exports = removeFromArray;