This file contains 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 characters
{ | |
"todos": [ | |
{ | |
"id": 1, | |
"title": "buy bread", | |
"completed": true | |
}, | |
{ | |
"id": 2, | |
"title": "buy milk", |
This file contains 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 characters
// ---- Module ---- | |
// есть проблема в том что все свойства типа public, нет инкапсуляции | |
var counter = { | |
counter: 0, | |
incrementCounter: function () { | |
return ++this.counter; | |
}, | |
resetCounter: function () { | |
return this.counter = 0; | |
} |
This file contains 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 characters
// ---- let const ---- | |
const a = 5; | |
let b = 10; | |
if (true) { | |
let a = 1; | |
let b = 2; | |
const c = 3; | |
console.log(a, b); // 1 2 |
This file contains 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 characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
</head> | |
<body> | |
<div class="info"> | |
Size page: <p class="info__size-page"></p> | |
Date: <p class="info__date"></p> |
This file contains 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 characters
// -------------- XMLHttpRequest -------------- | |
// 1. Создаём новый объект XMLHttpRequest | |
var xhr = new XMLHttpRequest(); | |
// 2. Конфигурируем его: GET-запрос на URL 'data.json' - синхронная обработка | |
xhr.open('GET', 'data.json', false); | |
// 3. Отсылаем запрос | |
xhr.send(); |
This file contains 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 characters
function Clock() { | |
this.start = function () { | |
setInterval(this.render.bind(this), 1000); | |
} | |
} | |
Clock.prototype.getTime = function () { | |
return new Date(); | |
} | |
Clock.prototype.render = function () { | |
console.log(this.getTime().getMinutes() + ":" + this.getTime().getSeconds()); |
This file contains 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 characters
// this | |
// 1. Шаблон вызова функции | |
var sum = function(a, b) { | |
console.log(this); // window | |
return a + b; | |
} | |
console.log(sum(1, 2)); | |
// исправим контекст вызова и перейдем к OOP |
This file contains 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 characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
</head> | |
<body> | |
<div id="dom"></div> | |
<script src="main.js"></script> |
This file contains 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 characters
function multiply(a, b) { | |
return a * b; | |
}; | |
function square(n) { | |
return multiply(n, n) | |
}; | |
function printSquare(n) { | |
var squared = square(n); |
This file contains 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 characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
<style> | |
form, form p, form div { | |
margin: 10px; | |
border: 1px solid blue; | |
} |
NewerOlder