i am new in javascript and i have to understand an appcelerator project. in appcelerator we need to code in java script.
var winForm = (function() {
var API = {};
API.list = [
{
title:'title1', hasChild:true, color:'#9B0B0B',font:'font'
},
{
title:'title2', hasChild:true, color:'#9B0B0B',font:'font'
},
{
title:'title3', hasChild:true, color:'#9B0B0B',font:'font'
}
];//end winList
return API;
})(); //end
module.exports = winForm;
Sorry for asking so much questions in one post.
list
is being set to an array (that's the [... ]
notation) consisting of 3 objects. Each object has 4 properties, title
, hasChild
, color
, and font
, with the respective values.winForm
(which is then stored in module.exports
).module
object, whatever that is. You should take the time to learn more about how javascript works. I recommend http://javascript.info/ as a great ramp up.
I would like to recommend some useful links, these will enrich your knowledge
1) the function is an immediate anonymous self executed expression function in the form of variable = (function() {}())
2) API is initialized to be an object (or hashtable) and its scope is inside that function
3) API.list is an array of objects, each one containing four pairs key:value
4) Function is self executed so when you return API object you assign it to the winForm variable
5) winForm
is the returning object and winForm.list
is the array.
Since you assign module.exports = winForm;
then module.exports.list
is your array
1.This function is called as anonymous function or rather you can say self executing function
2.It is creating an empty object
3.API.list is array of the object .. To define array [ ] these brackets are used and for object { }.
4. You are using the return function .. and the result is getting stored in module.export
5. Export is the method name .. There has to be a method object define somewhere in js . you can you this method to get your result
as in the winForm function and used for some purpose
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.