I'm new to coding and i'm just learning some JavaScript. I'm learning about using return versus console.log and how you can use return values in other functions. Anyway, I see that you can create a key-value pair using a function and the return statement. They gave an example like this:
function newObject(val) { return { prop: val } } newObject(50); // output would be: {prop:50}
I am a bit confused at this because what is the object of this key-value pair? The way I learned about creating objects is you do:
var newObject = { prop: 50 }
so here this key-value pair would belong to the newObject object which was declared as a variable. In the function example that I first gave, is the object still newObject except instead of it being declared as a variable it is a function?
a bit confused, maybe im getting ahead of myself. Unsure how this key-value pair that was made through a function would be assigned to an object.