คำอธิบายโจทย์
เขียน function solution(target, patch) ข้อมูลเข้าและผลลัพธ์เป็นค่า JSON ห้ามแก้ไขอาร์เรย์หรือออบเจ็กต์ข้อมูลเข้า ไม่รองรับไลบรารีภายนอก เครือข่าย หรือฟังก์ชันแบบอะซิงโครนัส target and patch are JSON values. A nonobject patch (including null and arrays) replaces the entire target. For an object patch, start with {} if target is not an object. Delete keys whose patch value is null; recursively apply all other keys. Replace arrays wholesale. Preserve input and treat '__proto__' and 'constructor' as ordinary data keys. Maximum depth 20. ขอบเขตข้อมูล: อาร์เรย์อินพุตแต่ละชุดมีไม่เกิน 50,000 รายการ สตริงไม่เกิน 1,000 ตัวอักษร ตัวเลขต้องเป็นค่าจำกัด จำนวนเต็มและผลรวมจำนวนเต็มอยู่ในช่วงจำนวนเต็มที่ปลอดภัยของ JavaScript ชนิดและความถูกต้องอื่นเป็นไปตามกฎด้านบน
ตัวอย่างข้อมูลเข้าและผลลัพธ์
ตัวอย่าง 1
อาร์กิวเมนต์ของฟังก์ชัน
[
{
"a": 1,
"b": 2
},
{
"a": null,
"c": 3
}
]ค่าที่ส่งคืน
{
"b": 2,
"c": 3
}ตัวอย่าง 2
อาร์กิวเมนต์ของฟังก์ชัน
[
{
"nested": {
"a": 1,
"b": 2
}
},
{
"nested": {
"a": 3
}
}
]ค่าที่ส่งคืน
{
"nested": {
"a": 3,
"b": 2
}
}ตัวอย่าง 3
อาร์กิวเมนต์ของฟังก์ชัน
[
{
"a": true
},
{
"a": false
}
]ค่าที่ส่งคืน
{
"a": false
}