Question about Javascript pattern

Page 66

getDocument(name, data) {
data = data || {};

}

What is function the pattern “data = data || {};”
So far as I can see it will evaluate to true.
Is it a way of checking that data has a value?

Thanks

In this case it is a coalescing operator. It checks that data is something valid and if not it is initialised as an empty object {}.

It is shorthand for data = (data != nil ? data : {})