Skip to content

Instantly share code, notes, and snippets.

@yogain123
Created December 10, 2017 21:07
Show Gist options
  • Save yogain123/6374decfc71d648eeb3c4a4052a9789c to your computer and use it in GitHub Desktop.
Save yogain123/6374decfc71d648eeb3c4a4052a9789c to your computer and use it in GitHub Desktop.
Mordern JavaScript
@yogain123
Copy link
Author

yogain123 commented Mar 6, 2022

Prototype


class Hola{
    constructor(){
        this.name="yogendra";
        console.log(this);
    }

    static div(){
        console.log("div");
    }

    sum(){
        console.log("sum");
    }
}

const h = new Hola();

console.log(Object.getPrototypeOf(h))   // {constructor: ƒ, sum: ƒ}

console.log(h.__proto__)   // {constructor: ƒ, sum: ƒ}

console.log(Hola.prototype); // {constructor: ƒ, sum: ƒ}


@yogain123
Copy link
Author

yogain123 commented Aug 6, 2022

Array.at()

Get the value at that position -> index passed
const arr = ["jack","yogi","abc"]
console.log(arr.at(0)) // "jack"
console.log(arr.at(-1)) // "abc"

@yogain123
Copy link
Author

IMG_4256

@yogain123
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment