<script src="1.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script>
let ace ={
age:20
}
let obj={
name:"www",
gender:"20",
sayHi(){
console.log("Hi");
}
}
sun.extend(obj,ace)
sun.extend({
sayHello(){console.log("hello");
}
})
console.log(ace);
sun.sayHello()
</script>
js里的
extend(a,b){
b=b||this
for (let key in a) {
b[key] = a[key]
}
}
直接调用sayHello()