Reputation: 108
Thanks in advance for your patience... Really trying to fill in weird gaps in my JS knowledge...
Analyzing other people's scripts and came across:
Var isTouch = "ontouchstart" in window;
What is the "in window" part doing? I've googled several basic variable declaration tutorials and it's not mentioned, and "in" is such a basic word, it's been hard to find answers.
Thanks,
JK
Upvotes: 2
Views: 97
Reputation:
isTouch
is now simply a boolean (true or false), as the in
operator returns a boolean:
var foo = {
bar : 42
},
hasBar = 'bar' in foo, // true
hasFoob = 'foob' in foo; // false
Upvotes: 1