I came across a piece of Javascript code on the internet that I do not understand. simplified snippet:
assocEmails?.includes(email)
what does the "?" do in this context? I searched around but could not get help on this question.
While searching around I came across another Javascript code snippet (on MDN):
(function() {
console.log(Array.prototype.includes.call(arguments, 'a')) // true
console.log(Array.prototype.includes.call(arguments, 'd')) // false
})('a','b','c')
The code works but I do not understand how it works and how I could utilise this kind of code in other situations. It looks like the first bracket defines an anonymous function followed by an immediate call to that function (in the second bracket).
Any pointers to documentation and further explanations would be appreciated.