Back to Content

SpeechRecognitionResultList: length property

files/en-us/web/api/speechrecognitionresultlist/length/index.md

latest804 B
Original Source

{{APIRef("Web Speech API")}}

The length read-only property of the {{domxref("SpeechRecognitionResultList")}} interface returns the length of the "array" — the number of {{domxref("SpeechRecognitionResult")}} objects in the list.

Value

A number.

Examples

This code is excerpted from our Speech color changer example.

js
recognition.onresult = (event) => {
  const color = event.results[0][0].transcript;
  diagnostic.textContent = `Result received: ${color}.`;
  bg.style.backgroundColor = color;

  console.log(event.results.length);
};

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also