wordpress - understanding the use of typeof -


I am trying to solve a problem in WordPress and when I am a Noble, I am stumped (Which is the type of part in the last bold). Can someone explain me in simple English?

  & lt; Input id = "et_pb_number" type = "text" class = "regular-text" value = "& lt;% = typeof (et_pb_number)! == 'undefined'? Et_pb_number: ''%" "/" In my opinion, does this mean that it will check the type of variable (javascript handling) variables (at_pb_number) and see if it is undefined, and then what will happen next?  

What should I do if I do not want to check the type of value?

The surrounding parts are not directly related to typing, is it the expression? When-True: When-False

These two are exactly the same:

  // Ternary form var test = typeof (et_pb_number)! == 'Undefined'? Et_pb_number: ''; Console.log (test); Test // if else block form var; If (typef et_pb_number! == 'undefined') {test = et_pb_number; } And {trial = ""; } Console.log (test);  

The Ternary operator is present in many programming languages ​​and can be technically used just like / else - but be careful! It is difficult to read (as you have experienced yourself) Sometimes it is difficult to read only Use it to return one or the other depending on any condition (in your example Used in this way). In a manner of speaking: It should be used generally (usually) if there is no side effect other than returning any value.

You can technically do this completely, but I will not recommend it (again: for reasons of perceptible: technically it is fine):

  // Do not do this (unless you really have very good reasons. Var some value = true; some value? $ ('Body') .html ('hello'): $ ('body 'Html' ('World')  

This example will directly replace the external world.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -