Skip to content

Instantly share code, notes, and snippets.

View ivankisyov's full-sized avatar
🤓
Console Logger, Level 4

Ivanman ivankisyov

🤓
Console Logger, Level 4
View GitHub Profile
@ivankisyov
ivankisyov / factory-functions-js.md
Created December 27, 2018 08:15
Factory Functions in JS

Factory Functions in JS

This is a functions which creates new object. This function is neither a constructor function, nor a "class".

function createPerson(name) {
  let person = {};
  person.name = name;
  return person;
}
@ivankisyov
ivankisyov / interfaces-in-typescript.md
Last active December 26, 2018 13:20
Interfaces in TypeScript

Interfaces in TypeScript

interface User {
  membership: string;
  active: boolean;
  status?: boolean; // optional prop
  [propName: string]: any; // not aware of the names of the rest of the props
}
@ivankisyov
ivankisyov / namespaces-typescript.md
Created December 26, 2018 10:13
Namespaces in TypeScript

Namespaces in TypeScript

appInfo.ts

namespace AppInfo {
  const version: string = "1.0.0";

  export function getVersion() {
    return version;
 }
@ivankisyov
ivankisyov / hasownproperty.md
Last active December 25, 2018 16:44
hasOwnProperty JS

hasOwnProperty

const person = {
  name: null
}

// create new object and set its __proto__ to point to person object
const ivan = Object.create(person);
@ivankisyov
ivankisyov / object-defineProperty.md
Last active December 25, 2018 17:22
Object.defineProperty

Object.defineProperty

Todo

MDN

@ivankisyov
ivankisyov / object-create.md
Last active December 25, 2018 17:12
Object.create

Object.create

const person = {
  name: null
}

// create new object and set its __proto__ to point to person object
const ivan = Object.create(person);
@ivankisyov
ivankisyov / classes-in-typescript.md
Last active December 25, 2018 16:04
Classes in TypeScript

Classes in TypeScript

Types of properties

  • public(the default case)
  • private
    • you can only access it from the class. Cannot set/read it from outside.
    class Human {
      private type: string = "terran";
      constructor(public name: string) {
    
@ivankisyov
ivankisyov / rest-parameters.md
Created December 25, 2018 11:57
Rest parameters

Rest parameters

function logNumbers(...args) {
  console.log(args); // type: array
}

logNumbers(1,2)
// [1, 2]
@ivankisyov
ivankisyov / inheritance-js.md
Last active December 24, 2018 12:27
"Inheritance" in JS

"Inheritance" in JS

class Human {
    constructor(name) {
        this.name = name
    }
   
}
@ivankisyov
ivankisyov / static-methods-js.md
Created December 24, 2018 12:13
Static methods in JS "Classes"

Static methods in JS "Classes"

Methods that must be invoked on the class itself, not on its instances

class Human {
  constructor(name) {
    this.name = name;
  }