javascript(js) 物件(object) 比對
javascript(js) 物件(object) 比對
資料來源: https://www.delftstack.com/zh-tw/howto/javascript/compare-objects-javascript/
線上執行(線上編譯): https://www.programiz.com/javascript/online-compiler/
code01(object ->json string)
const fruit1 = { name: 'Apple', price: '2' }; const fruit2 = { name: 'Apple', price: '2' }; console.log(JSON.stringify(fruit1) === JSON.stringify(fruit2));//true fruit2.price=1; console.log(JSON.stringify(fruit1) === JSON.stringify(fruit2));//false