Hey guys am new to javascript development .i have learned about javascript objects and i have done some code with it ..My code
function afunction() {
var num = 10;
return num;
}
afunction.randomfunction(function() {
return {
"name": "somename"
"age": 12
}
})
When i called the function with afunction.randomfunction.name; it gives me error like
" underfined is not a function"
i dont know why am getting like this .what i need is that i need to get the the value of name object by using afunction.randomfunction.name;
i know am doing something wrong ..Hope you guys can help me .to find out my mistake.
afunction.randomfunction.nameis not correct code in this context becauserandomfunctiondoesn't exist, nor is it a child ofafunction. Why do you have this code? What are you wanting to achieve?afunctiondoesn't have the property ofrandomfunction, soafunction.randomfunctionisundefined.afunction.randomfunctionsupposed to be? Is it supposed to be a function? If so, you have to define it as a function before you can call it.