That is a interface definition, is not actual javascript code. It only means that that value can be null
. It means exactly the same as in C#
Take into account that in javascript you don't declare the return value, and there you are seeing it.
سؤال
Have read some documentation in MDN:
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
When I have seen the overview section I was wondering, what does that mean?
In C# there is a nullable data type: http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx
With the similar syntax to JS sample, which is in the screenshot from docs:
int? num = null;
It means, that a value types, which are struct like int
can hold not just some value, but could a null
value could be assigned to it.
But! JavaScript has a duck-typing and it is also a dynamic language with the weak typification. In JS I can assign null or undefined to any value or even not set anything, it isn't a strict language as C#.
So... It can't be a nullable type as in C#, so what is it?
المحلول
That is a interface definition, is not actual javascript code. It only means that that value can be null
. It means exactly the same as in C#
Take into account that in javascript you don't declare the return value, and there you are seeing it.