TiddlyWiki.org

Ticket #285 (closed enhancement: fixed)

Opened 2 years ago

Last modified 1 year ago

Array.prototype.pushUnique can be simplified

Reported by: UdoBorkowski Assigned to: JeremyRuston
Priority: minor Milestone: 2.2
Component: core Version:
Severity: low Keywords:
Cc:

Description

The initial check

	if(unique != undefined && unique == false) {

can be simplified to

	if(unique === false) {

I.e. the function may look like this:

Array.prototype.pushUnique = function(item,unique)
{
	if(unique === false) {
		this.push(item);
	} else {
		if(this.indexOf(item) == -1)
			this.push(item);
	}
};

Change History

08/02/07 14:10:00 changed by JeremyRuston

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in changeset:1472

08/02/07 14:10:08 changed by JeremyRuston

  • milestone set to 2.2.