基本上我试图看看能否这样做:
$('td').on('input', function() {
var _this = $(this); // preserve reference to the input field here
if(saveTimeout) clearTimeout(saveTimeout);
saveTimeout = setTimeout(function() {
console.log(_this)
$.ajax({
method: "POST",
url: "updatedatabase.php",
data: {
content: _this.text(),
date: _this.siblings().first().text(),
prod: $('tr:first-child th:nth-child(' + (_this.index() + 1) + ')').text(),
old: old
}
})
.done(function( msg ) {
alert( msg );
});
}, 2500);
});
我认为你不能,但只是检查:)
答案 0 :(得分:1)
在解构函数参数时可以创建一个对象吗?
没有。解构仅允许您将现有值分配给变量。它不允许您创建新值。
答案 1 :(得分:0)
var state = {
lastMessage: {
owner: 'lastMessageOwnerID'
},
owner: 'currentMessageOwnerID'
}
function isSameMessageOwner ({
lastMessage: { owner: lastMessage },
owner: currentMessage
}) {
return lastMessage === currentMessage
}
var isSameOwner = isSameMessageOwner(state)
console.log(isSameOwner)