Object.assign
方法用於對象的合並,將源對象(source)的所有可枚舉屬性,復制到目標對象(target)
const target = { a: 1 }; // 目標對象 const source1 = { b: 2 }; // 源對象 const source2 = { c: 3 };
// 源對象
Object.assign(target, source1, source2); target // {a:1, b:2, c:3}
Object.assign
方法用於對象的合並,將源對象(source)的所有可枚舉屬性,復制到目標對象(target)
const target = { a: 1 }; // 目標對象 const source1 = { b: 2 }; // 源對象 const source2 = { c: 3 };
// 源對象
Object.assign(target, source1, source2); target // {a:1, b:2, c:3}
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。