Skip to content

remove global variable self? #7262

Closed
Closed
@lzl124631x

Description

@lzl124631x

What problem does this feature solve?

A library should use as less global variables as possible.

One time, I copy & pasted code from one function to another and forgot to change self back to this. The code could run but only after a while I was shocked that this self is actually pointing to window, not my viewmodel. Global variables, especially one with this common name, might cause confusion and should be renamed.

What does the proposed API look like?

not applicable

Activity

ktsn

ktsn commented on Dec 17, 2017

@ktsn
Member

Vue does not have self as a global variable but window has in default. https://developer.mozilla.org/en-US/docs/Web/API/Window/self

lzl124631x

lzl124631x commented on Dec 17, 2017

@lzl124631x
Author

Oh thanks @ktsn That's embarrassing. I didn't know that.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ktsn@lzl124631x

        Issue actions

          remove global variable `self`? · Issue #7262 · vuejs/vue