`on start` tab confused how to use

But thanks for showing me that.

It is now a problem of me REMEMBERING it for future use. CRAFT disease is getting worse for me. :wink:

function HelloWorld(){
    return "Hello"
}

AND

const HelloWorld = () => {
    return "Hello"
}

are no different on the surface

arrow functions are "new" if that is the right word, but do allow to use surrounding context

1 Like

Where would that go?

I don't mind the alternatives being suggested, but alas I shall say/state:

I am still very much at the start/bottom of the learning curve of JavaScript and the command/syntax.

Ok.

Again: Handy to know. But will it survive CRAFT disease?

In the subflow JSON that you shared

Sorry, but you are going to have to be more clear on what that means.

(not against you, but it is sort of worrying how people think I am smarter than I am.)
I really know only just above nothing about Node-Red/JavaScript and most languages.

Its a rabbit hole

Taking these examples...

function Hello(){
   return this.world // returns the property `world` from the "parent" that called Hello
}
const  Hello = () > {
   return this.world // returns the property `world` from the "parent" that this code resides 
}

So the this. is a ...... command ?

it relates to the context it is being called from

1 Like

Thanks, but I am now floundering.

I'll try to remember that as it seems like a handy trick to know.

1 Like

think of this as the body of code calling another body of code (there is more to it off course)

a function will treat this as the thing that called it
an arrow function will treat this as the body of code that this arrow function lives

1 Like

Yeah, ok.

But please understand I have no....... base knowledge...... about it.

So I can see what you say, but the deeper meaning - and the ability to know how to use it in the future is not really there.

Most of my stuff is done badly - as I make a lot of mistakes.
Yes, I have got better over the past..... x years since I first started.

But taking this new knowledge and applying it to all my old code is near impossible for me as it wasn't written in the nicest way.

I have spent a lot of time recently having to restructure a lot of code because mistakes raised their heads and made a lot of pain for me when something unexpected happened.

Kind of good, but also painful with all the rewriting of code.

This even newer stuff is........ conceptual for me.
I can see it, and sort of understand it, but I don't know where/how to put it in my brain so I know where it is next time I need it.

So as good as it is, if I can't index it correctly, it becomes lost with all the other stuff.

But sincerely: Thanks.

1 Like

Copy the code snippet in to a function node, with lots of comments about how and where it was used etc
Then save that to your library with a meaningful name, so you can find it next time you want it :wink:

image

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.