今天写代码的时候遇到了一个感觉很奇怪很诡异的问题
/**
* Created by zhang on 5/26/2017.
*/
var Wiw = function () {
this.config = {
"form":{
"height":300,
"width":500
},
"content":"please edit you text!",
"handler":function () {
//empty
}
}
console.log(this.config);
}
Wiw.prototype = {
ext:function (cfg) {
console.log("2");
$.extend(this.config,cfg);
//执行合并
}
}
document.getElementById("a").onclick = function () {
new Wiw().ext({
form:{}
})
}
非常普通,首先new出来 初始化 然后调用合并方法 按道理说输出的结果应该是 合并前的config属性对象和合并后的 但实际的情况确是
他的表现就像是合并后再输出 但是调用顺序却又是正常的
更加奇怪的是
当你把
console.log(this.config); 改成
console.log(this.config.form)
结果又恢复了正常 
而在fireFox之中一直都很正常

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号