Skip to content

Instantly share code, notes, and snippets.

@skrajewski
Created May 31, 2021 07:04
Show Gist options
  • Select an option

  • Save skrajewski/3c6690519a8b13bfdc3ac5ae203cacdb to your computer and use it in GitHub Desktop.

Select an option

Save skrajewski/3c6690519a8b13bfdc3ac5ae203cacdb to your computer and use it in GitHub Desktop.

Revisions

  1. skrajewski revised this gist May 31, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion test.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    function prepareTest() {
    this.test = "abcd";
    this.test = "abcd";
    }

    // global
  2. skrajewski created this gist May 31, 2021.
    17 changes: 17 additions & 0 deletions output.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    Output in Browser:

    ```js
    undefined
    undefined
    {test: "abcd"}
    "abcd"
    ```

    Output in Node:

    ```js
    undefined
    undefined
    prepareTest { test: 'abcd' }
    undefined
    ```
    15 changes: 15 additions & 0 deletions test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    function prepareTest() {
    this.test = "abcd";
    }

    // global
    console.log(this.test);

    const a = prepareTest();
    const b = new prepareTest()

    console.log(a);
    console.log(b);

    // global
    console.log(this.test);