Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Js For of loop error in atom #596

Open

Description

@axe-z

Simple, latest version 1.30

for loop,
the for of autocompletes (without any added snippets) this:

for (variable of iterable) {

}

always f...s me up later.

should be
for (LET variable of iterable) {

}

Activity

  1. chfritz commented on Sep 16, 2018

    @chfritz
  2. Arcanemagus commented on Sep 16, 2018

    @Arcanemagus
  3. axe-z commented on Sep 16, 2018

    @axe-z
    Author

    It's not a huge deal anyway, but the for IN is ok(var), regular for loop too :

    for (var variable in object) {
    if (object.hasOwnProperty(variable)) {

    }
    } && for (var i = 0; i < array.length; i++) {
    array[i]
    }

    Might also be time to use the LET keyword !
    I always, for no good reason mind you... , wake up and figure out the variable's missing after a few seconds of debugging.and YES, I've created my own snippet by now, but still, this should be an easy fix.

  4. fd-rey commented on Nov 21, 2018

    @fd-rey
    Contributor

    I've the same issue, for...of is creating code that produces ReferenceError.
    I think that a possible solution could be modify this file:
    https://github.com/atom/language-javascript/blob/master/snippets/language-javascript.cson

    setting this line
    'for of': 'prefix': 'forof' 'body': 'for (${1:variable} of ${2:iterable}) {\n\t$3\n}'

    to this one (add var before the variable)
    'for of': 'prefix': 'forof' 'body': 'for (var ${1:variable} of ${2:iterable}) {\n\t$3\n}'

  5. axe-z commented on Nov 21, 2018

    @axe-z
    Author
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

      Issue actions