Skip to content

Instantly share code, notes, and snippets.

View mkczarkowski's full-sized avatar
馃殺
Shipping products

Marcin Czarkowski mkczarkowski

馃殺
Shipping products
View GitHub Profile
// Do celu =>! (if you know what I mean)
Adder.prototype.addToArray = function (arr) {
return arr.map(x => x + this.value);
}
const Adder = (val) => {
this.val = val;
}
const addTwo = new Adder(2); // TypeError: Adder is not a constructor
const algoSmart = {
likes: 52,
getLikes: () => console.log(this.likes),
setLikes: function(value) {
this.likes = value;
},
};
algoSmart.getLikes(); // undefined
algoSmart.setLikes(100000);
<button id="example">Click me</button>
.on {
background-color: #0288d1;
}
button = document.querySelector('#example');
button.addEventListener('click', () => {
console.log(this); // Window!
this.classList.toggle('on');
});
const myPreciousSecret = `I <3 AlgoSmart`;
console.log(myPreciousSecret); // "I <3 AlgoSmart"
console.log(typeof myPreciousSecret); // "string"
console.log(myPreciousSecret.length); // 14
// Pre-ES6.
var myFavouriteMeal = "Pizza";
console.log('I love ' + myFavouriteMeal + '!'); // "I love Pizza!"
// ES6.
const myFavouriteMeal = "Pizza";
console.log(`I love ${myFavouriteMeal}!`); // "I love Pizza!"
console.log(`2 + 2 = ${2+2}`); // "2 + 2 = 4"
console.log(`2 + 2 = ${add(2, 2)}`); // "2 + 2 = 4"
console.log(`Is Marcin 23 years old? ${true || false}`;`) // "Is Marcin 23 years old? true"
var message = [
'Du偶o linijek, ',
'du偶o problem贸w.'
].join('\n');
var message = 'Du偶o linijek, \n' +
'du偶o problem贸w.';