-
-
Save ufocoder/d6bb31ae33ca3ba8eff3d43d77324ab8 to your computer and use it in GitHub Desktop.
Revisions
-
ufocoder revised this gist
Aug 1, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -163,9 +163,9 @@ console.log(-100 > 0 > 100); ```js var sexism = '👧' < '👨'; console.log(sexism) ``` 14) -
ufocoder revised this gist
Aug 1, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -163,7 +163,7 @@ console.log(-100 > 0 > 100); ```js var equality = '👧' < '👨'; console.log(equality) ``` -
ufocoder revised this gist
Aug 1, 2019 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -174,4 +174,19 @@ console.log(equality) var santaSpread = [...'🎅🏿'] console.log(santaSpread); ``` 15) ```js var obj = { '0': 'a', '1': 'b', '2': 'c', 'length': 3 } obj.__proto__ = Array.prototype console.log(...obj) ``` -
ufocoder revised this gist
Aug 1, 2019 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -166,4 +166,12 @@ console.log(-100 > 0 > 100); var equality = '👧' == '👨'; console.log(equality) ``` 14) ```js var santaSpread = [...'🎅🏿'] console.log(santaSpread); ``` -
ufocoder revised this gist
Aug 1, 2019 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -157,4 +157,13 @@ console.log(foo.x); ```js console.log(-100 < 0 < 100); console.log(-100 > 0 > 100); ``` 13) ```js var equality = '👧' == '👨'; console.log(equality) ``` -
ufocoder revised this gist
Aug 1, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -154,7 +154,7 @@ console.log(foo.x); 12) ```js console.log(-100 < 0 < 100); console.log(-100 > 0 > 100); ``` -
ufocoder revised this gist
Aug 1, 2019 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -149,4 +149,12 @@ console.log(foo.x); 11) Основное отличие стрелочных функцию Ответ: Основное отличие стрелочных функций от обычных функций, даже если не смотреть на то, что они короче, заключается в том, что стрелочные функции не задают собственное значение для this. Вместо этого они используют значение this блока, в который они включены. В вышеприведённом примере при обращении к this.x каждую секунду будут выводиться числа 1, 2, 3, и так далее. При использовании в похожей ситуации обычной функции, this имело бы значение undefined, что привело бы к выводу NaN. Тело стрелочной функции представляет собой её возвращаемое значение. Это делает особенно удобным использование стрелочных функций в промисах. Обычные функции, в отличие от стрелочных, должны явно возвращать некое значение, иначе автоматически будет возвращено undefined. 12) ``` console.log(-100 < 0 < 100); console.log(-100 > 0 > 100); ``` -
ufocoder revised this gist
Aug 1, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ var foo = 'Hello'; (function() { var bar = ' World'; console.log(foo + bar); })(); console.log(foo + bar); -
ufocoder revised this gist
Aug 1, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -104,7 +104,7 @@ console.log(b); 7) Чему равно foo.x ? ```js var foo = {n: 1}; var bar = foo; -
ufocoder revised this gist
Aug 1, 2019 . 1 changed file with 39 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,41 +1,54 @@ 1) Что покажут эти два alert()? ```js var foo = 'Hello'; (function() { var bar = ' World'; alert(foo + bar); })(); console.log(foo + bar); ``` Ответ: 'Hello World' и ReferenceError: bar is not defined. 2) Что вернет следующий код? ```js var Employee = { company: 'xyz' } var emp1 = Object.create(Employee); delete emp1.company console.log(emp1.company); ``` Ответ: Код выше будет выводить xyz в качестве вывода. Здесь объект emp1 получил компанию в качестве прототипа. Оператор удаления не удаляет свойство прототипа. 3) Что вернет следующий код? ```js var trees = ["xyz", "xxxx", "test", "ryan", "apple"]; delete trees[3]; console.log(trees.length); ``` Ответ: 5. delete() не влияет на длину массива. 4) Что будет в консоли? ```js var number = 0; console.log(number++); console.log(++number); console.log(number); ``` Ответ: C Постфиксный унарный оператор ++: @@ -48,40 +61,56 @@ console.log(number); Результат: 0 2 2. 5) Что произойдет при выполнении следующего куска кода? ```js myname = "global"; function func() { console.log(myname); var myname = "local"; console.log(myname); } func(); ``` Ответ: Интерпретатор JavaScript всегда перемещает («поднимает») объявления функций и переменных в начало области видимости (вверх текущего скрипта или функции). Код в вопросе аналогичен следующему: ```js myname = "global"; function func() { var myname; console.log(myname); myname = "local"; console.log(myname); } func(); ``` 6) Что вернет следующие строки? ```js var a = !function(){}() var b = !function(){} console.log(a); console.log(b); ``` Ответ: true, false 7) Чему равно foo.x ? ``` var foo = {n: 1}; var bar = foo; foo.x = foo = {n: 2}; console.log(foo.x); ``` Главное на что здесь стоит обратить внимание, так это то, что foo на которую ссылается foo.x “устанавливается” перед тем как foo изменится. foo.x ссылается на старое значение foo. Это значит, что в старом foo появиться новое свойство x равное {n: 2} . А в новое foo запишется {n: 2} . ``` -
AntonGorelov revised this gist
Jul 30, 2019 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -110,11 +110,14 @@ foo.x = foo = {n: 2}; В разметке используется тэг picture, который совсем недавно вошел в спецификацию. Код валидный вплоть до последнего изображения в атрибуте srcset; 320y — невалидное значение. Если изменить y на w, то код будет валидным полностью. 9) Что такое атрибут longdesc? Ответ: Этот атрибут был сделан для того, чтобы позволить более детально описывать изображения, нежели это позволяет сделать атрибут alt. Интересная вещь: вместо того, чтобы являть собой описание изображения (как это делает атрибут alt), longdesc указывает на гиперссылку, содержащую описание. 10) 018 - 017 = ? Ответ: 3. В JavaScript префикс 0 преобразует число в восьмеричное. Однако 8 не используется в восьмеричном виде, и любое число, содержащее 8, будет автоматически преобразовано в десятичное число. Следовательно, 018 - 017 по сути эквивалентно десятичному выражению 18 - 15, потому что 017 – восьмеричное число, а 018 – десятичное. 11) Основное отличие стрелочных функцию Ответ: Основное отличие стрелочных функций от обычных функций, даже если не смотреть на то, что они короче, заключается в том, что стрелочные функции не задают собственное значение для this. Вместо этого они используют значение this блока, в который они включены. В вышеприведённом примере при обращении к this.x каждую секунду будут выводиться числа 1, 2, 3, и так далее. При использовании в похожей ситуации обычной функции, this имело бы значение undefined, что привело бы к выводу NaN. Тело стрелочной функции представляет собой её возвращаемое значение. Это делает особенно удобным использование стрелочных функций в промисах. Обычные функции, в отличие от стрелочных, должны явно возвращать некое значение, иначе автоматически будет возвращено undefined. -
AntonGorelov revised this gist
Jul 30, 2019 . 1 changed file with 43 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -75,4 +75,46 @@ func(); !function(){}() !function(){} ``` Ответ: true, false 7) Чему равно foo.x ? ``` var foo = {n: 1}; var bar = foo; foo.x = foo = {n: 2}; ``` Главное на что здесь стоит обратить внимание, так это то, что foo на которую ссылается foo.x “устанавливается” перед тем как foo изменится. foo.x ссылается на старое значение foo. Это значит, что в старом foo появиться новое свойство x равное {n: 2} . А в новое foo запишется {n: 2} . ``` // bar { n: 1, x: { n: 2 } } ``` Так как при дальнейшем выводе foo.x наше foo ссылается на его новое значение, в котором отсутствует x , то соответственно foo.x будет не определенно — undefined . Ответ: undefined. 8) Валидный код? ``` <figure> <picture> <source media="(min-width: 40em)" srcset="large.jpg 1024w, medium.jpg 640w, small.jpg 320y"> <img src="medium.jpg" alt="London by night"> </picture> <figcaption>A landscape of London by night</figcaption> </figure> ``` В разметке используется тэг picture, который совсем недавно вошел в спецификацию. Код валидный вплоть до последнего изображения в атрибуте srcset; 320y — невалидное значение. Если изменить y на w, то код будет валидным полностью. 9) Что такое атрибут longdesc? Ответ: Этот атрибут был сделан для того, чтобы позволить более детально описывать изображения, нежели это позволяет сделать атрибут alt. Интересная вещь: вместо того, чтобы являть собой описание изображения (как это делает атрибут alt), longdesc указывает на гиперссылку, содержащую описание. 10) 018 - 017 = ? Ответ: 3. В JavaScript префикс 0 преобразует число в восьмеричное. Однако 8 не используется в восьмеричном виде, и любое число, содержащее 8, будет автоматически преобразовано в десятичное число. Следовательно, 018 - 017 по сути эквивалентно десятичному выражению 18 - 15, потому что 017 – восьмеричное число, а 018 – десятичное. 11) Основное отличие стрелочных функцийю Ответ: Основное отличие стрелочных функций от обычных функций, даже если не смотреть на то, что они короче, заключается в том, что стрелочные функции не задают собственное значение для this. Вместо этого они используют значение this блока, в который они включены. В вышеприведённом примере при обращении к this.x каждую секунду будут выводиться числа 1, 2, 3, и так далее. При использовании в похожей ситуации обычной функции, this имело бы значение undefined, что привело бы к выводу NaN. Тело стрелочной функции представляет собой её возвращаемое значение. Это делает особенно удобным использование стрелочных функций в промисах. Обычные функции, в отличие от стрелочных, должны явно возвращать некое значение, иначе автоматически будет возвращено undefined. -
AntonGorelov revised this gist
Jul 30, 2019 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ alert(foo + bar); Ответ: 'Hello World' и ReferenceError: bar is not defined. 2) Что вернет следующий код? ```js var Employee = { company: 'xyz' } @@ -22,15 +22,15 @@ console.log(emp1.company); emp1 получил компанию в качестве прототипа. Оператор удаления не удаляет свойство прототипа. 3) Что вернет следующий код? ```js var trees = ["xyz", "xxxx", "test", "ryan", "apple"]; delete trees[3]; console.log(trees.length); ``` Ответ: 5. delete() не влияет на длину массива. 4) Что будет в консоли? ```js let number = 0; console.log(number++); console.log(++number); @@ -48,7 +48,7 @@ console.log(number); Результат: 0 2 2. 5) Что произойдет при выполнении следующего куска кода? ```js myname = "global"; function func() { console.log(myname); @@ -60,7 +60,7 @@ func(); Ответ: Интерпретатор JavaScript всегда перемещает («поднимает») объявления функций и переменных в начало области видимости (вверх текущего скрипта или функции). Код в вопросе аналогичен следующему: ```js myname = "global"; function func() { var myname; @@ -71,7 +71,7 @@ function func() { func(); ``` 6) Что вернет следующие строки? ```js !function(){}() !function(){} ``` -
AntonGorelov revised this gist
Jul 30, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ 1) Что покажут эти два alert()? ```js var foo = 'Hello'; (function() { var bar = ' World'; -
AntonGorelov revised this gist
Jul 30, 2019 . 1 changed file with 15 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,34 +1,41 @@ 1) Что покажут эти два alert()? ``` var foo = 'Hello'; (function() { var bar = ' World'; alert(foo + bar); })(); alert(foo + bar); ``` Ответ: 'Hello World' и ReferenceError: bar is not defined. 2) Что вернет следующий код? ``` var Employee = { company: 'xyz' } var emp1 = Object.create(Employee); delete emp1.company console.log(emp1.company); ``` Ответ: Код выше будет выводить xyz в качестве вывода. Здесь объект emp1 получил компанию в качестве прототипа. Оператор удаления не удаляет свойство прототипа. 3) Что вернет следующий код? ``` var trees = ["xyz", "xxxx", "test", "ryan", "apple"]; delete trees[3]; console.log(trees.length); ``` Ответ: 5. delete() не влияет на длину массива. 4) Что будет в консоли? ``` let number = 0; console.log(number++); console.log(++number); console.log(number); ``` Ответ: C Постфиксный унарный оператор ++: @@ -41,16 +48,19 @@ console.log(number); Результат: 0 2 2. 5) Что произойдет при выполнении следующего куска кода? ``` myname = "global"; function func() { console.log(myname); var myname = "local"; console.log(myname); } func(); ``` Ответ: Интерпретатор JavaScript всегда перемещает («поднимает») объявления функций и переменных в начало области видимости (вверх текущего скрипта или функции). Код в вопросе аналогичен следующему: ``` myname = "global"; function func() { var myname; @@ -59,8 +69,10 @@ function func() { console.log(myname); // "local" } func(); ``` 6) Что вернет следующие строки? ``` !function(){}() !function(){} ``` Ответ: true, false -
AntonGorelov created this gist
Jul 30, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ 1) Что покажут эти два alert()? var foo = 'Hello'; (function() { var bar = ' World'; alert(foo + bar); })(); alert(foo + bar); Ответ: 'Hello World' и ReferenceError: bar is not defined. 2) Что вернет следующий код? var Employee = { company: 'xyz' } var emp1 = Object.create(Employee); delete emp1.company console.log(emp1.company); Ответ: Код выше будет выводить xyz в качестве вывода. Здесь объект emp1 получил компанию в качестве прототипа. Оператор удаления не удаляет свойство прототипа. 3) Что вернет следующий код? var trees = ["xyz", "xxxx", "test", "ryan", "apple"]; delete trees[3]; console.log(trees.length); Ответ: 5. delete() не влияет на длину массива. 4) Что будет в консоли? let number = 0; console.log(number++); console.log(++number); console.log(number); Ответ: C Постфиксный унарный оператор ++: Возвращает значение (0) Инкрементирует значение (теперь число равно 1) Префиксный унарный оператор ++: Инкрементирует значение (число теперь равно 2) Возвращает значение (2) Результат: 0 2 2. 5) Что произойдет при выполнении следующего куска кода? myname = "global"; function func() { console.log(myname); var myname = "local"; console.log(myname); } func(); Ответ: Интерпретатор JavaScript всегда перемещает («поднимает») объявления функций и переменных в начало области видимости (вверх текущего скрипта или функции). Код в вопросе аналогичен следующему: myname = "global"; function func() { var myname; console.log(myname); // "undefined" myname = "local"; console.log(myname); // "local" } func(); 6) Что вернет следующие строки? !function(){}() !function(){} Ответ: true, false