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
{ | |
"compilerOptions": { | |
"target": "es5", | |
"module": "commonjs", | |
"moduleResolution": "node", | |
"emitDecoratorMetadata": true, | |
"experimentalDecorators": true, | |
"allowSyntheticDefaultImports": true, | |
"sourceMap": true, | |
"noEmit": true, |
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 | |
function hello() { | |
return 'Hello'; | |
} | |
hello() // hello | |
hello() // hello | |
// function with params |
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 | |
var a = { | |
name: 'Вася', | |
getName: function () { | |
return this.name; | |
}, | |
getContext: function() { | |
return this; | |
} |
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; | |
} |
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> | |
</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
// 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
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
// -------------- 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
<!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> |
OlderNewer