Оператор `"+"` в данном случае прибавляет `1` как строку, и затем `0`.
Оператор `"-"` работает только с числами, так что он сразу приводит `""` к `0`.
-
В некоторых браузерах `parseInt` без второго аргумента интерпретирует `09` как восьмиричное число.
`null` при численном преобразовании становится `0`
`undefined` при численном преобразовании становится `NaN`
\ No newline at end of file
diff --git a/1-js/2-first-steps/14-types-conversion/1-primitive-conversions-questions/task.md b/1-js/2-first-steps/14-types-conversion/1-primitive-conversions-questions/task.md
index b5519c80..f4b4928e 100644
--- a/1-js/2-first-steps/14-types-conversion/1-primitive-conversions-questions/task.md
+++ b/1-js/2-first-steps/14-types-conversion/1-primitive-conversions-questions/task.md
@@ -15,7 +15,6 @@ true + false
"4" - 2
"4px" - 2
7 / 0
-parseInt("09")
" -9\n" + 5
" -9\n" - 5
5 && 2
diff --git a/1-js/4-data-structures/11-datetime/6-get-seconds-today/solution.md b/1-js/4-data-structures/11-datetime/6-get-seconds-today/solution.md
index 00cbc9ee..f58da115 100644
--- a/1-js/4-data-structures/11-datetime/6-get-seconds-today/solution.md
+++ b/1-js/4-data-structures/11-datetime/6-get-seconds-today/solution.md
@@ -17,3 +17,12 @@ function getSecondsToday() {
alert( getSecondsToday() );
```
+Альтернативное решение -- получить часы/минуты/секунды и преобразовать их все в секунды:
+
+```js
+//+ run
+function getSecondsToday(){
+ var d = new Date();
+ return d.getHours() * 3600 + d.getMinutes() * 60 + d.getSeconds();
+};
+```
\ No newline at end of file
diff --git a/1-js/4-data-structures/11-datetime/7-get-seconds-to-tomorrow/solution.md b/1-js/4-data-structures/11-datetime/7-get-seconds-to-tomorrow/solution.md
index a00492fc..8aade9c9 100644
--- a/1-js/4-data-structures/11-datetime/7-get-seconds-to-tomorrow/solution.md
+++ b/1-js/4-data-structures/11-datetime/7-get-seconds-to-tomorrow/solution.md
@@ -14,4 +14,3 @@ function getSecondsToTomorrow() {
return Math.round(diff / 1000); // перевести в секунды
}
```
-
diff --git a/1-js/5-functions-closures/5-closures-module/article.md b/1-js/5-functions-closures/5-closures-module/article.md
index 4e6f690f..21b46eaa 100644
--- a/1-js/5-functions-closures/5-closures-module/article.md
+++ b/1-js/5-functions-closures/5-closures-module/article.md
@@ -174,7 +174,7 @@ function work() {
```html
Подключим библиотеку
-
+
Функция _.defaults() добавляет отсутствующие свойства.
-
+
diff --git a/2-ui/5-widgets/4-template-lodash/3-menu-template/solution.view/index.html b/2-ui/5-widgets/4-template-lodash/3-menu-template/solution.view/index.html
index cf883245..5c497247 100755
--- a/2-ui/5-widgets/4-template-lodash/3-menu-template/solution.view/index.html
+++ b/2-ui/5-widgets/4-template-lodash/3-menu-template/solution.view/index.html
@@ -4,7 +4,7 @@
-
+
diff --git a/2-ui/5-widgets/4-template-lodash/3-menu-template/source.view/index.html b/2-ui/5-widgets/4-template-lodash/3-menu-template/source.view/index.html
index fed4bbb2..26bc8af1 100755
--- a/2-ui/5-widgets/4-template-lodash/3-menu-template/source.view/index.html
+++ b/2-ui/5-widgets/4-template-lodash/3-menu-template/source.view/index.html
@@ -4,7 +4,7 @@
-
+
diff --git a/2-ui/5-widgets/4-template-lodash/article.md b/2-ui/5-widgets/4-template-lodash/article.md
index 1b970a53..38908bc3 100644
--- a/2-ui/5-widgets/4-template-lodash/article.md
+++ b/2-ui/5-widgets/4-template-lodash/article.md
@@ -24,7 +24,7 @@
С первой группой виджетов -- вопросов нет. Добавляем обработчики, и дело сделано.
-Интересно начинается со второй группы, и совсем интересно -- с третьей группой.
+Здесь нам интересна вторая группа. Третья -- это по существу оптимизация с едиными шаблонами на клиенте и сервере, рассмотрим её позже.
## Зачем нужны шаблоны?
@@ -241,7 +241,7 @@ var template = document.getElementById('menu-template').innerHTML;
```html
-
+
+
+
+
+
```
В шаблоне допущена ошибка, поэтому отладчик остановит выполнение.
@@ -523,13 +543,13 @@ function(obj) {
-**LoDash пытается нам помочь. Он добавляет к шаблонам специальный идентификатор [sourceURL](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl), который служит аналогом "имени файла". На картинке он отмечен красным.**
+Библиотека LoDash пытается нам помочь, подсказать, в каком именно шаблоне произошла ошибка. Ведь из функции это может быть неочевидно.
+
+Для этого она добавляет к шаблонам специальный идентификатор [sourceURL](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl), который служит аналогом "имени файла". На картинке он отмечен красным.
По умолчанию `sourceURL` имеет вид `/lodash/template/source[N]`, где `N` -- постоянно увеличивающийся номер шаблона. В данном случае мы можем понять, что эта функция получена при самой первой компиляции.
-**Это, конечно, лучше чем ничего, но, как правило, его имеет смысл заменить `sourceURL` на свой.**
-
-Это делается при компиляции дополнительным параметром `sourceURL`:
+Это, конечно, лучше чем ничего, но, как правило, его имеет смысл заменить `sourceURL` на свой, указав при компиляции дополнительный параметр `sourceURL`:
```js
...
@@ -537,7 +557,7 @@ var compiled = _.template(tmpl, null, {sourceURL: '/template/menu-template'});
...
```
-Попробуйте запустить [исправленный пример](/tutorial/widgets/template-error-sourceurl/) и вы увидите в качестве имени файла `/template/menu-template`.
+Попробуйте запустить [исправленный пример](template-error-sourceurl/) и вы увидите в качестве имени файла `/template/menu-template`.
[warn header="Не определена переменная -- ошибка"]
Кстати говоря, а в чём же здесь ошибка?
@@ -551,7 +571,7 @@ var compiled = _.template(tmpl, null, {sourceURL: '/template/menu-template'});
Шаблоны полезны для того, чтобы отделить HTML от кода. Это упрощает разработку и поддержку.
-В этой главе подробно разобрана система шаблонизации из библиотеки [LoDash](https://github.com/bestiejs/lodash).
+В этой главе подробно разобрана система шаблонизации из библиотеки [LoDash](https://lodash.com).
Теперь, когда мы с ней знакомы, мы можем как использовать её в своих проектах, так и перейти к более глобальному рассмотрению подходов к шаблонизации.
diff --git a/2-ui/5-widgets/4-template-lodash/menu-template.view/index.html b/2-ui/5-widgets/4-template-lodash/menu-template.view/index.html
index bb5f5698..f2db58da 100644
--- a/2-ui/5-widgets/4-template-lodash/menu-template.view/index.html
+++ b/2-ui/5-widgets/4-template-lodash/menu-template.view/index.html
@@ -3,7 +3,8 @@
-
+
+
diff --git a/2-ui/5-widgets/4-template-lodash/menu-template.view/menu.js b/2-ui/5-widgets/4-template-lodash/menu-template.view/menu.js
index 062334c4..440c6345 100644
--- a/2-ui/5-widgets/4-template-lodash/menu-template.view/menu.js
+++ b/2-ui/5-widgets/4-template-lodash/menu-template.view/menu.js
@@ -7,11 +7,11 @@ function Menu(options) {
}
function render() {
- var elemHtml = options.template({title: options.title});
+ var html = options.template({title: options.title});
elem = document.createElement('div');
- elem.innerHTML = elemHTML;
- elem = elem.firstChild;
+ elem.innerHTML = html;
+ elem = elem.firstElementChild;
elem.onmousedown = function() {
return false;
diff --git a/2-ui/5-widgets/4-template-lodash/index.html b/2-ui/5-widgets/4-template-lodash/template-error-sourceurl.view/index.html
old mode 100755
new mode 100644
similarity index 71%
rename from 2-ui/5-widgets/4-template-lodash/index.html
rename to 2-ui/5-widgets/4-template-lodash/template-error-sourceurl.view/index.html
index 321b8b7e..528c3354
--- a/2-ui/5-widgets/4-template-lodash/index.html
+++ b/2-ui/5-widgets/4-template-lodash/template-error-sourceurl.view/index.html
@@ -2,7 +2,7 @@
-
+
-
+
diff --git a/2-ui/5-widgets/5-custom-events/menu-event.view/index.html b/2-ui/5-widgets/5-custom-events/menu-event.view/index.html
index 548e4bde..eaaa01ed 100755
--- a/2-ui/5-widgets/5-custom-events/menu-event.view/index.html
+++ b/2-ui/5-widgets/5-custom-events/menu-event.view/index.html
@@ -4,7 +4,7 @@
-
+