I don’t understand what the ! does in "!object[id].hasOwnProperty(“tracks”). I also don’t understand the purpose of using brackets to assign value in the next line "object[id][prop] = [value]; Record Collection
== equal
!= not equal
That is the “not” operator. It casts the value as a boolean and inverts it.
!false
is the same as true
.
!true
is the same as false
.
This is usually used with the “truthiness” of a value, usually to check whether something is defined and not null.
const user = {
username: 'ArielLeslie',
isAwesome: true,
}
if (!user.firstName) { // if we don't know the user's first name
askForName(user);
}
1 Like
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.