var JsObject = {};
= function() //Define a function namespace under the JsObject object
{
/*In the following code, arguments are parameters passed in the function. When the function does not clearly define the parameters,
Functions can also be passed in parameters and received using arguments. arguments are similar to arrays.
If multiple parameters are passed in, they will be saved in order. The value method is: arguments[0], arguments[1]....*/
var a = arguments,o = null,d,rt;
for(var i = 0; i < ; i++)
{
d = a[i].split('.'); //Split the passed parameters with the symbol '.' and put them into the d array.
rt = d[0];
//Judge whether the first value in the array is undefined. If it is not defined, it is defined as an empty object {} and assign it to the variable o
eval('if (typeof ' + rt + ' == "undefined"){'
+ rt + ' = {};} o = ' + rt + ';');
for(var j = 1; j < ; j++)
{
/* Loop through each value of the array d as a key and add it to object o. If the key exists in o, then take the value of o, if
If it does not exist, then the value is assigned to an empty object {} */
o[d[j]] = o[d[j]] || {};
o = o[d[j]];
}
}
}
(""); //Declare the namespace:
= function() //Define the class Student under the namespace
{
//Define the variable in the class Student and assign the initial value, but the access permission of this variable is public
= 's001';
= 'Xiao Ming';
= 'Male';
}
var s = new (); //Create an object of the Student class
alert('Student number:'+);
alert('Name:'+);
alert('Gender:'+);