Does JavaScript have something similar to the null propagating operating in C#?

This question already has an answer here:


ANSWERS:


You can do simply like:

if(myobject && myobject.someprop == something)

Or typeof validation:

if(typeof myobject != 'undefined' && myobject.someprop == something)

Checking an object's property within a valid object:

if(myobject && myobject.hasOwnProperty('your_property'))

You have a lot of possibilities in verifying objects or variables, but the all the operators work in that way in Javascript..

Here you can see more detailed ways to code your validation: How to check a not-defined variable in JavaScript



 MORE:


 ? C# 6 Null Conditional Check
 ? Roslyn C#6 ?. operator compilation looks messy in generic types
 ? Null Conditional Operator, not behaving as expected on some machines
 ? Null conditional operator to "nullify" array element existence
 ? How can I use the Nullable Operator with the Null Conditional operator?
 ? C# 6 Null Conditional Operator for Method Fails
 ? C# 6 null propagation what value is set when object is null
 ? Operator '?' cannot be applied to operand of type 'T'
 ? Null propagated ?.First() vs .FirstOrDefault()
 ? How to compound Expressions of similar types?