4

Seiously though , Javascript Developer community are toxic shit! All I did was asked a question regarding the syntax.

They started to curse me and call me names , like what the fuck? I just want to know some syntax. Dont have to be an arse.

At least Elixir community is polite.

Comments
  • 1
    What’s the question? Am I not here to help you?
  • 1
    @Cyanide finally someone come to the rescue....

    I wrote this

    ```javascript
    export default class A
    {
    async foo(a, b)
    {
    return 'something';
    }

    async bar(c, d)
    {
    this.foo(c, d);
    }
    }

    ```

    and go an "undefined" error. So in my case how to I call a function within the same class?

    I tried remove the `this` still return the same result
  • 1
    @johnmelodyme problem is that the second function is not returning. Add

    return this.foo()
  • 0
    @dmonkey actually that function would return something else after assign into another function .
  • 2
    Are you trying to return an object in foo and accessing it's property gives you undefined? Async functions return the value wrapped in a Promise. To wait for it to resolve in other async function you can use await keyword.
  • 4
    1. You may have forgotten to add a return statement in bar
    2. When you call an async function, either await it or make the callee sync and return the resulting promise. It's technically legal to return a promise from an async function but it's better to be clear in your intentions. Always either await or return promises, or reflect in a comment on why you chose not to. Unhandled promise rejections are terrible, not to mention they crash Node.
    3. If you're new to JS, remember that this will not work:
    ```
    const a = new A()
    const myfunction = a.bar
    myfunction(1, 2)
    ```
    This will fail due to how `this` works in JS, MDN has a really good article about it. It's not complex at all, but it's not very convenient which is why I make an effort to avoid classes and OOP altogether and use factories and composition instead.
  • 0
    @joas this help...
  • 0
    @lbfalvy thanks !
  • 1
    JavaScript developers are angry that they open their eyes and see JavaScript all day. The poor things.

    Also, you're a bitch. (I'm a JS dev)
  • 3
    You must not be asking in the right community. The one I've joined just ignores you XD
  • 1
    @Angry well, that's equally sad. Is it me, or collective silence can also be offending?
  • 1
    @Angry try the one in telegram.... They will scold you and pick a fight with you ... They will say "how you don't know this ? Are you stupid ..." Something like that ...every JavaScript group I joined behave this way idk why.

    But luckily in my discord I found a server name coding help. They seems ok technically solve my doubt. Not to mention people in Devrant helped me too.
  • 0
    @johnmelodyme well, it is somehow expected that you read a good book before asking questions in some places.

    * JavaScript the good parts
    * JavaScript Allongé

    Are 2 good oldies that tackle some of the most annoying parts is JS by focusing on what makes JS great.

    The most confusing things, like the function binding problem that was mentioned earlier will be covered in a good book, also the different rules for hoisting, scoping and closures.

    The ones I mentioned would probably not be up to date with the classes and async/await grammars, but those are kind of new and pretty much covered by any decent article online.

    Also if you're into typescript, the TS language reference is pretty good once you've got the basics and the quirks of JS.
  • 0
    @galileopy any recommendation for a good book?
  • 1
    @johnmelodyme

    * JavaScript the good parts
    * Javascript Allongé (I think this one is free to read online)
  • 1
    @galileopy thanks!
Add Comment