Skip to content

Instantly share code, notes, and snippets.

@jaketrent
Forked from ryanflorence/gist:61935031ff729f072d9b
Last active August 29, 2015 14:20

Revisions

  1. @ryanflorence ryanflorence revised this gist May 4, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@ rather say this?


    ```js
    // what people who say "use semicolons!!" say
    class Foo {
    prop = {
    }; // yes
    @@ -41,6 +42,7 @@ function boing () {
    Or this?

    ```js
    // what people who say "don't use semicolons!" say
    /*yes*/;[1,2,3].map()
    /*yes*/;(function () {})()
    // which are two things I haven't done in the last 3 years, mind you
  2. @ryanflorence ryanflorence created this gist May 4, 2015.
    53 changes: 53 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    When a beginner asks you "when do I use semi-colons?" would you
    rather say this?


    ```js
    class Foo {
    prop = {
    }; // yes

    static bar () {
    if (stuff) {
    doStuff(); // yes
    } // no

    for (var key in obj) {
    } // no

    return {
    }; // yes
    } // no

    foo () {
    } // no
    } // no

    Foo.prop = {
    }; // yes

    things.map(thing => thing.name /*no*/)

    var boing = function () {
    }; // yes

    function boing () {
    } // no

    /*no*/[1,2,3].map(); // yes
    /*no*/(function () {})(); // yes
    ```

    Or this?

    ```js
    /*yes*/;[1,2,3].map()
    /*yes*/;(function () {})()
    // which are two things I haven't done in the last 3 years, mind you
    ```

    In the end, I'd rather not talk about semi-colons, and just do what
    people around me want me to do, but when teaching a beginner who asks
    (and they ALWAYS ask this) "when do I use a semi-colon", I just put my
    face in my hands and say "I don't have any answers for you".