var a = () => {}
- это объявление функции, на которую ссылается переменная a
var a = () => {}
эквивалентно var a = function(){}
this.sayHello = () => {
console.log(`Меня зовут ${this.surname} ${this.name} ${this.patronymic}`);
}
this.sayHello = function() {
console.log(`Меня зовут ${this.surname} ${this.name} ${this.patronymic}`);
}
this
будет работать неправильно, потому что в стрелочную функцию this попадет как this из функции getFIO, а в обычную функцию попадет как this анонимной функции (на которую ссылается sayHello) collection = [{ name: 'Apple',
length: '5',
id: '21',
image: 'a2ff5'
},{ name: 'Banana',
length: '6',
id: '22',
image: 'e8za2'},{ name: 'Banana',
length: '6',
id: '22',
image: 'e8za2'}
];
ids = [];
newCollection = collection.filter(el => {
if (ids.includes(el.id)) {
return true;
}
ids.push(el.id);
return false;
})
console.log(newCollection)
function myFunction (id, input) {
input.addEventListener("change", function() {
localStorage.setItem(id, input.value);
});
}
document.addEventListener("DOMContentLoaded", function() {
var ids = ["1", "2", "3"];
for (var id of ids) {
var input = document.getElementById(id);
input.value = localStorage.getItem(id);
myFunction(id, input);
}
});
if (a>b){
a = 100;
}else{
a = 0;
}
a = 0;
if(a > b){
a = 100;
}
function setName(data){
let name;
if(data.firstName && data.lastName){
name = data.firstName + ' ' + data.lastName;
}else{
name = data.firstName + ' ' + data.lastName;
}
data.name = name;
}
function start(){
if(something.isStarted){
return;
}
something.start();
}