function makeNoSense(x) {
this.x = x;
}
makeNoSense(5);
console.log(x);// x 已经成为一个值为 5 的全局变量
function test(){
this.x = 1;
alert(this.x);
}
test(); // 1
var myObject = {
value :0,
increment:function (inc){
this.value += typeof inc ==='number' ? inc:1;
}
};
myObject.increment();
console.log(myObject.value); //1
myObject.increment(2);
console.log(myObject.value); //3
function Point(x, y){
this.x = x;
this.y = y;
}
var p1 = new Point(3,2);
console.log(p1.x+","+p1.y);//3,2
var x = 4;
function Point(x, y){
this.x = x;
this.y = y;
}
var p1 = new Point(3,2);
console.log(p1.x+","+p1.y);//3,2
function Point(x, y){
this.x = x;
this.y = y;
this.moveTo = function(x, y){
this.x = x;
this.y = y;
console.log(this.x+","+this.y);
}
}
var p1 = new Point(0, 0);
var p2 = {x: 0, y: 0};
p1.moveTo(1, 1); //1,1
p1.moveTo.apply(p2, [10, 10]);//10,10
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有