L'oggetto document.getElementsByTagName("input") non è un array, è una HTMLCollection (è molto simile a un array, ma non dispone degli stessi metodi dell'array).

Esiste il metodo push? Usiamolo.

codice:
var foo = document.getElementsByTagName("input");
var inputPassword = [];
if (foo) {
	for (var e = 0; e < foo.length; e++){
		if (foo[e].type === "password") { inputPassword.push(foo[e]); }
	}
}
Originariamente inviato da TrueLies
per cui: no, ti tocca prelevare tutta la array degli elementi input, e poi fare un ciclo e individuare da te quelli il cui type=="password"
Esiste per la verità un metodo più sintetico, assai simile alla via suggerita dalla domanda iniziale:

codice:
var aMiaCollezione = [];
Array.prototype.forEach.call(document.getElementsByTagName("input"), function (oInputEl) { if (oInputEl.type === "password") { this.push(oInputEl); } }, aMiaCollezione);
alert(aMiaCollezione.length);
Ma credo che non vada bene per le versioni di Internet Explorer inferiori alla 9. Per cui se vuoi percorrere questa via devi implementare questo codice in testa al tuo script per renderlo compatibile con tutti i browser:

codice:
if (!Array.prototype.forEach) {
	Array.prototype.forEach = function(fun /*, thisp */) {
		"use strict";
		if (this === void 0 || this === null) { throw new TypeError(); }
		var t = Object(this);
		var len = t.length >>> 0;
		if (typeof fun !== "function") { throw new TypeError(); }
		var thisp = arguments[1];
		for (var i = 0; i < len; i++) { if (i in t) { fun.call(thisp, t[i], i, t); } }
	};
}
(fonte: https://developer.mozilla.org/en/Jav...#Compatibility)