我有一個關於這個小Javascript程序的行5的問題。使用行5,audioNumber
上的括號/參數位於內部圓括號的內部/旁邊,因爲audioNumber
是.indexOf
的參數。鑑於此行上的編號爲1
的參數爲.splice
,因此它位於外部圓括號內。這是正確的理解爲什麼audioNumber
和1
是他們在哪裏行5?Javascript - 關於嵌套括號/參數
function playAudio(audioNumber) {
var audio = document.getElementById('sound' + audioNumber);
audio.play();
var nonPlaying = [1, 2, 3, 4, 5, 6, 7];
nonPlaying.splice(notPlaying.indexOf(audioNumber), 1); // line 5
nonPlaying.forEach(function(id) {
document.getElementById('sound' + id).pause();
document.getElementById('sound' + id).currentTime = 0;
});
};
是的,這是一個正確的理解 –
嚴格地說,那些是參數,而不是參數:https://stackoverflow.com/questions/156767/whats-the-difference-between-an-argument-and-a-parameter – JLRishe
謝謝各位的意見。 – Emma45