Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Так ошибка в первой строке, говорит Uncaught TypeError: showlog is not a function
- showlog();
- window.onresize = function () {
- showlog();
- };
- var showlog = function () {
- console.log(1);
- };
- // А так работает
- window.onload = function () {
- showlog();
- };
- window.onresize = function () {
- showlog();
- };
- var showlog = function () {
- console.log(1);
- };
- // А не работало в первом случае потому что функция стояла наже строки вызова
- // Т.к. когда функцию вызывали интерпретатор её саму ещё не нашёл
- var showlog = function () {
- console.log(1);
- };
- showlog();
- window.onresize = function () {
- showlog();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement