Skip to content

Instantly share code, notes, and snippets.

@vikneshwar
Last active June 24, 2021 13:30
Show Gist options
  • Save vikneshwar/45d24e8b99dbdb088de35bd199d60a2a to your computer and use it in GitHub Desktop.
Save vikneshwar/45d24e8b99dbdb088de35bd199d60a2a to your computer and use it in GitHub Desktop.

Revisions

  1. vikneshwar revised this gist Jun 24, 2021. 1 changed file with 22 additions and 21 deletions.
    43 changes: 22 additions & 21 deletions interview.js
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,14 @@
    //pure functions
    //pure functions
    //given a input will always return a same output
    //will not cause side effects
    const add = (a,b) => a + b;
    const add = (a, b) => a + b;

    //impure function 1
    const magicLetter = '*'
    const createMagicPhrase = (phrase) => `${magicLetter}abra${phrase}`
    const magicLetter = "*";
    const createMagicPhrase = (phrase) => `${magicLetter}abra${phrase}`;

    //impure function 2
    const fetchLoginToken = externalAPI.getUserToken
    const fetchLoginToken = externalAPI.getUserToken;

    //Closure
    //Ex:
    @@ -21,46 +21,47 @@ console.log(x); //2

    //let and const are hoisted but not assigned a value so will throw error
    //Ex:
    var x = 10
    var x = 10;
    {
    console.log(x); //throws undefined error
    let x = 20
    let x = 20;
    }

    //IIFE
    // Why IIFE
    var x = 10;
    console.log(x);
    (function(){
    console.log(x);
    var x = 2;
    console.log(x);
    (function () {
    console.log(x);
    var x = 2;
    console.log(x);
    })();

    // .call .apply .bind
    // ES6 Features
    // Node Architecture


    if(new Boolean(false)) {
    console.log("TEST")
    if (new Boolean(false)) {
    console.log("TEST");
    }

    //function hoisting
    foo()
    var foo = function(){
    console.log("TEST")
    }
    foo();
    var foo = function () {
    console.log("TEST");
    };

    //Promises

    let data = {
    name: "viknesh"
    name: "viknesh",
    };

    let data_1 = data;
    data_1.name = "xyz"
    data_1.name = "xyz";

    console.log(data);

    //first class functions
    //first class functions

    // node advantage vs disadvantage
  2. vikneshwar revised this gist Mar 22, 2019. 1 changed file with 13 additions and 3 deletions.
    16 changes: 13 additions & 3 deletions interview.js
    Original file line number Diff line number Diff line change
    @@ -11,11 +11,21 @@ const createMagicPhrase = (phrase) => `${magicLetter}abra${phrase}`
    const fetchLoginToken = externalAPI.getUserToken

    //Closure
    //Hoisting
    //Ex:

    console.log(x);
    //Hoisting
    //Ex:
    console.log(x); // undefined
    var x = 2;
    console.log(x);
    console.log(x); //2

    //let and const are hoisted but not assigned a value so will throw error
    //Ex:
    var x = 10
    {
    console.log(x); //throws undefined error
    let x = 20
    }

    //IIFE
    // Why IIFE
  3. vikneshwar revised this gist Mar 6, 2019. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion interview.js
    Original file line number Diff line number Diff line change
    @@ -51,4 +51,6 @@ let data = {
    let data_1 = data;
    data_1.name = "xyz"

    console.log(data);
    console.log(data);

    //first class functions
  4. vikneshwar revised this gist Mar 6, 2019. No changes.
  5. vikneshwar revised this gist Mar 6, 2019. 1 changed file with 43 additions and 0 deletions.
    43 changes: 43 additions & 0 deletions interview.js
    Original file line number Diff line number Diff line change
    @@ -9,3 +9,46 @@ const createMagicPhrase = (phrase) => `${magicLetter}abra${phrase}`

    //impure function 2
    const fetchLoginToken = externalAPI.getUserToken

    //Closure
    //Hoisting

    console.log(x);
    var x = 2;
    console.log(x);

    //IIFE
    // Why IIFE
    var x = 10;
    console.log(x);
    (function(){
    console.log(x);
    var x = 2;
    console.log(x);
    })();

    // .call .apply .bind
    // ES6 Features
    // Node Architecture


    if(new Boolean(false)) {
    console.log("TEST")
    }

    //function hoisting
    foo()
    var foo = function(){
    console.log("TEST")
    }

    //Promises

    let data = {
    name: "viknesh"
    };

    let data_1 = data;
    data_1.name = "xyz"

    console.log(data);
  6. vikneshwar created this gist Mar 6, 2019.
    11 changes: 11 additions & 0 deletions interview.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    //pure functions
    //given a input will always return a same output
    //will not cause side effects
    const add = (a,b) => a + b;

    //impure function 1
    const magicLetter = '*'
    const createMagicPhrase = (phrase) => `${magicLetter}abra${phrase}`

    //impure function 2
    const fetchLoginToken = externalAPI.getUserToken