0
基本上我想看看我能做到這一點:解構函數參數時可以創建一個對象嗎?
var state = {
lastMessage: {
owner: 'lastMessageOwnerID'
},
owner: 'currentMessageOwnerID'
}
function isSameMessageOwner ({ lastMessage, owner: currentMessage: { owner } }) {
return lastMessage.owner === currentMessage.owner
}
var isSameOwner = isSameMessageOwner(state)
我不認爲你可以,但只是檢查:)
該語法不對。 – Pointy
我不明白。你想創建什麼對象? – 2016-12-01 18:02:18
@torazaburo我想創建'currentMessage'對象,以便函數內部可以使用'currentMessage.owner' –