Skip to content

Instantly share code, notes, and snippets.

View olddustysocksunderthecouch's full-sized avatar

Adrian Bunge olddustysocksunderthecouch

View GitHub Profile
import { someData } from ‘./path/to/file.js’;
import * as upToYou from ‘./path/to/file.js’;
class Person {
constructor () {
this.name = ‘Douglas Adams’;
}
}
const person = new Person();
console.log(person.name); //logs: ‘Douglas Adams’
class Person {
name = ‘Douglas Adams’;
}
const person = new Person();
console.log(person.name); //logs: ’Douglas Adams’
class Person{
name = ‘Douglas Adams’;
printAuthorsName () {
console.log(this.name); // this is required to refer to the class!
}
}
const person = newPerson();
person.printAuthorsName();
class Person{
name = ‘Douglas Adams’;
printAuthorsName = () => {
console.log(this.name);
}
}
const person = new Person();
person.printAuthorsName();
class Human{
species = ‘human’;
}
const person = new Person();
class Person extends Human{
name = ‘Douglas Adams’;
printAuthorsName = () => {
console.log(this.name);
}
const oldArray = [1, 2, 3];
const newArray = […oldArray, 4, 5]; // This now is[1, 2, 3, 4, 5];
const oldObject = {
name: ‘Douglas Adams’
};
const newObject = {
…oldObject,
age: 42
};
{
name: ‘Douglas Adams’,
age: 42
}