728x90
반응형
$.extend({
deepMerge: function(target, source) {
for (let key in source) {
if (source[key] !== null) { // null일 경우 덮어쓰지 않음
target[key] = source[key];
}
}
return target;
}
});
let a = { others: "기타사항" };
let b = { others: null };
let result = $.extend.deepMerge({}, a, b);
console.log(result.others); // "기타사항" (b.others가 null이므로 덮어쓰지 않음)
728x90
반응형
'Front > JS & jQuery' 카테고리의 다른 글
[js] $.extend(a, b)와 $.extend({}, a, b)의 차이 (1) | 2025.06.26 |
---|---|
[js] 병합 시 특정 값만 유지하고 싶다면? (0) | 2025.06.24 |
[js] $.extend 사용시 주의점 (0) | 2025.06.23 |
[js] cancelAnimationFrame() (0) | 2025.06.21 |
[js] requestAnimationFrame()의 내부 동작 원리 (1) | 2025.06.20 |