Reputation: 105
I just defined object and it's property inside a function:
function objectDefinition() {
const object = {
property: value
}
}
How can I get it from outside the function? Would something like the code below work?
object = {}
function objectDefinition() {
const object = {
property: value
}
}
If it doesn't work, is there any other way?
Upvotes: 0
Views: 31
Reputation: 781726
You should return the object from the function.
function objectDefinition() {
const object = {
property: value
}
return object;
}
let someVar = objectDefinition();
Upvotes: 2