jsmini / extend Goto Github PK
View Code? Open in Web Editor NEWRecursively assign object properties to the target object, similar to jQuery's $.extend.
License: MIT License
Recursively assign object properties to the target object, similar to jQuery's $.extend.
License: MIT License
不能处理循环引用
// case 1, 自身有环
const obj = {
foo: {
bar:null
}
}
obj.foo.bar = obj.foo
// case 2, 互相引用
const obj1 = {
foo: {
bar:null
}
}
const obj2 = {
baa: {
caa:obj1.foo
}
}
obj1.foo.bar = obj2.baa
extend(true, obj1,obj2);
我试了下 jquery 也不能处理这种, 看了下他源码, 处理的方式和你是一样的, 能解释下为什么要这么处理吗,如果真有循环引用的话, 会一直不能 return target
,那么这个判断条件就一直是 false
呀.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.