In a word, the object in JavaScript is a function, a method.
(i) the first type:
A, declared object: var jhsoft = Jhsoft | | {}; or Var jhsoft=new Object ();
b, add attribute:Jhsoft.currenturl = document. url;//Current Page
C, Add Method:
Jhsoft.trim = function (str) {//Remove spaces
if (str = = null) return "";
str = str.replace (/[\r\n]/g, "");
str = str.replace (/[]/g, "");
str = str.replace ("", "");
return $.trim (str);
};
The second type:
var jhsoft={
Currenturl:document. url,//Current Page
Trim:function (str) {//Remove spaces
if (str = = null) return "";
str = str.replace (/[\r\n]/g, "");
str = str.replace (/[]/g, "");
str = str.replace ("", "");
return $.trim (str);
};
}
The third type:
var jhsoft=new function (Currenturl)
{
This. Currenturl=currenturl,//Current page
this.trim= function (str) {//Remove spaces
if (str = = null) return "";
str = str.replace (/[\r\n]/g, "");
str = str.replace (/[]/g, "");
str = str.replace ("", "");
return $.trim (str);
};
}
Several ways that JavaScript creates objects and properties