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
var person = { | |
firstName: 'John', | |
lastName: 'Snow' | |
}; | |
var newPerson = person; | |
newPerson.lastName = 'Summer'; | |
// person.lastName теперь 'Summer' |
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 sum(a, b) { | |
var result = a + b; | |
return result; | |
} | |
// использование: | |
sum(1, 2) // 3 |
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 ask(question, yes, no) { | |
if (confirm(question)) { | |
yes(); | |
} else { | |
no(); | |
} | |
} | |
function showOk() { | |
alert( "Вы согласились." ); |
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 ask(question, yes, no) { | |
if (confirm(question)) yes() | |
else no(); | |
} | |
ask( | |
"Вы согласны?", | |
function() { alert("Вы согласились."); }, | |
function() { alert("Вы отменили выполнение."); } | |
); |
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
var foo = function () { | |
var a = 3; | |
var b = 5; | |
var bar = function () { | |
var b = 7; | |
var c = 11; // a === 3, b === 7, c === 11 | |
a += b + c; // a === 21, b === 7, c === 11 | |
}; | |
// a === 3, b === 5, c === undefined | |
bar(); |
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
var article1 = { | |
id: 1, | |
createdAt: new Date('2012-04-04T24:00:00') | |
}; | |
var article2 = { | |
id: 1, | |
createdAt: new Date('2014-04-04T24:00:00') | |
} |
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
.selector { | |
/* Positioning */ | |
position: absolute; | |
z-index: 10; | |
top: 0; | |
right: 0; | |
/* Display & Box Model */ | |
display: inline-block; | |
overflow: hidden; |
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 sayHi(name) { | |
var phrase = "Привет, " + name; | |
alert( phrase ); | |
} | |
sayHi('Вася'); // Привет, Вася | |
alert(phrase) // undefined |
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
var userName = "Вася"; | |
function sayHi() { | |
alert( userName ); // "Вася" | |
} |
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
var phrase = 'Привет'; | |
function sayHi(name) { | |
alert(phrase + ', ' + name); | |
} | |
sayHi('Вася'); // Привет, Вася (*) | |
phrase = 'Пока'; |