Код: Выделить всё
< /code>
в первом файле (файл "script.js") я написал этот код < /p>
function testing() {
console.log("does it show in the console");
}
testing()
setTimeout(()=> testing(), 3000)
< /code>
во втором файле (файл "main.js") я написал этот код < /p>
function testing() {
console.log("this will override it");
}
testing()
< /code>
Результат, который я получил на консоли < /p>
does it show in the console script.js:20
this will override it main.js:2
this will override it main.js:2
< /code>
на основе знаний, которые я имею, я ожидал объявления функции (testing()
console.log("does it show in the console");
}
testing()
setTimeout(()=> testing(), 3000)
function testing() {
console.log("this will override it");
}
testing()
< /code>
Результат на консоли < /p>
this will override it script.js:27
this will override it script.js:27
this will override it script.js:27
< /code>
Это было не очень смущено, я бы предпочел сказать, что я узнал что-то новое, потому что я попробовал то же самое с одним внешним файлом JavaScript и встроенным тегом скрипта JavaScript
внешний JavaScript script.js file < /p>
Подробнее здесь: https://stackoverflow.com/questions/796 ... script-eng