I was trying to learn about async/promises/callbacks/js modules/etc... However, when I was trying to run a simple module which only required a file, and ran a function that only returned the parameter back, node was not outputting the result correctly. By this I mean that it would only sometimes return the value, and sometimes not.
I am pretty new so I could be wrong, but from what I understand this is async in node(?). But while researching I was only finding functions which do things like load, wait, timeout, etc. in lists for things that use async. But it seems that everything I run in node, no matter how simple runs with async and will not consistently output values? Here is an example of what I ran and recieved in the node console:
> function test(input){
... return input;
... }
> test('a')
> test('a')
'a'
>
> test(5)
> test(5)
5
>
Like I said, I was working on learning about a few things, but it started by looking into modules, so I was also wondering what a common 'pattern'(?) for handling this is, when exporting modules. Thanks.
Edit:
I'm not sure if I made it very clear, but for the most part I was really just wondering why a function as simple as this wouldn't be working, when the only functions I have seen people talk about async with are functions that are obviously waiting, in a sense. Not simple functions like this. I havent tried putting a callback with this yet, but I assume that works. I just didn't think you needed them for functions as simple as this?