私は、この O'Reilly Book の Web オーディオ チュートリアルに取り組んでいます。
次のコードは、オーディオ ファイルを一時停止して再生を再開するシステムを作成することを想定しています。
// Assume context is a web audio context, buffer is a pre-loaded audio buffer.
var startOffset = 0;
var startTime = 0;
function pause() {
  source.stop();
  // Measure how much time passed since the last pause.
  startOffset += context.currentTime - startTime;
}
function play() {
  startTime = context.currentTime;
  var source = context.createBufferSource();
  // Connect graph
  source.buffer = this.buffer;
  source.loop = true;
  source.connect(context.destination);
  // Start playback, but make sure we stay in bound of the buffer.
  source.start(0, startOffset % buffer.duration);
}
ただし、pause()関数を実行すると、次のエラーが発生します。
Uncaught ReferenceError: source is not defined 
私の観点からすると、これはキーワードsourceで定義されているvarため、関数にスコープが設定されているplay()ため、にアクセスできないために発生しpause()ます。キーワードを削除すると、var実際に問題が解決します。私の推論が正しいと誰かが私を安心させることができますか? これは単なるタイプミスですか、それとも私が理解していない根本的な原則がありますか? (本の正誤表を確認しましたが、そこには言及されていません。)