array/remove-last module

requires

  • Array() class

    global

    methods

    • .removeLast(item:any)

      Removes the last occurrence of an item

code

/* istanbul ignore if */
if (typeof define !== "function") {
	var define = require("amdefine")(module);
}

define(function (require) {
	"use strict";

	/*meta({
		"name": "Array",
		"type": "class",
		"global": true
	})*/

	require("../class/method");
	require("../shim/array");

	var meta = require("../meta");

	Array.method(
		meta({
			"name": "removeLast",
			"description": "Removes the last occurrence of an item",
			"arguments": [{
				"name": "item",
				"type": "any"
			}]
		}),
		removeLast
	);

	function removeLast (item) {
		var index = this.lastIndexOf(item);

		if (isFound(index)) {
			this.splice(index, 1);
		}
	}

	function isFound (index) {
		return index > -1;
	}
});
Page built with api-meta