以下只给出几个实例。
=========================
<html>
<head>
<script type="text/javascript">
function Login(){
this.id1 = "你能取得的值";
var id2 = "你还想要的值";
this.$log = function(__){
__.$ = function(IdName){
return eval(IdName);
}
}
}
console.log(new Login().id1); //你能取得的值
var obj = {};
new Login().$log(obj);
console.log(obj.$("id2")); //你还想要的值
console.log(function doLogin2(obj){
new Login().$log(obj);
return new Login().id1 + " and " + obj.$("id2")
}({}))
</script>
<title></title>
</head>
<body>
<pre>
//http://bbs.csdn.net/topics/310099388
</pre>
</body>
</html>
=========================
<html>
<head>
<script type="text/javascript">
var e=function(m,n){return m+n+a};
function fa() {
this.a=12;
this.d= e(2,3);
this.b=function(x){
c(x);
}
function c(x) {
console.log(" this is from c:"+x);
console.log(" this is from c:"+this.d);
}
b(a);
}
fa();
console.log(" a:"+a); //????
</script>
<title></title>
</head>
<body>
<pre>
</pre>
</body>
</html>
=========================
<html>
<head>
<script type="text/javascript">
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}
// console.log("Class:"+Class);
var Login = Class.create();
// console.log("Login:"+Login);
Login.prototype = {
initialize: function() { },
id1:11,
id2:22
}
function doLogin2 (){
var login = new Login();
login.id3=33;
console.log(login.id1);
console.log(login.id2);
console.log(login.id3);
}
// console.log("doLogin2:"+doLogin2);
doLogin2();
</script>
<title></title>
</head>
<body>
<pre>
//http://bbs.csdn.net/topics/310099388
</pre>
</body>
</html>