I have this code below:
<!DOCTYPE html>
<html>
<body>
<script>
function zz(){
var location = {
firstName: "John",
lastName : "Doe",
id : 5566,
fullName : function() {
return this.firstName + " " + this.lastName;
}
};
return this;
}
var abc= zz();
console.log(abc); //This works, but it is the the window objects location, I want the location I have defined
console.log(some code here to print out John);
console.log(some code here to print out Doe);
</script>
</body>
</html>
I choose location as the object name to learn about more about scope collision.
But now I can't figure out how to get to the variables I have defined. I know I have an object named location wrapped in a function zz
I know the object location has a firstName property of John I know also the object location has a method fullName that will return the John Doe back to the calling reference.
So what do I need to do to output for example John to the console?
Thanks,