Javascript | | there is an error problem.

   var res={
            optionMsg:""
        }
         ""+ res.data || res.optionMsg
         //"undefined"

         res.data || res.optionMsg
         //
         res.data || res.optionMsg+""
         //

Why do I return undefined before the text?
text is returned after the correct
what is the case?

Jun.08,2022

operator + is higher than | | has higher priority , so "Operation failure" + res.data | | res.optionMsg equals ("Operation failure" + res.data) | | res.optionMsg , res.data is undefined, so it is also equivalent to ("Operation failure" + undefined) | | res.optionMsg is equivalent to "Operation failure undefined" | | res.optionMsg

|
Menu