...

View Full Version : Meaning of || symbol



Blowpipe
01-11-2012, 03:21 PM
Hi there,

I am trying to find out what the meaning of || is and how I am able to write it up on my computer when writing function scripts.

I copied the symbol from another website and it is used in this context:

if(var=="" || var2=="" {
alert("something here");
return false
}else{
return true;
}

I haven't been able to find the meaning in any of my searches.

Thanks ahead of time

BP

hershey.
01-11-2012, 03:38 PM
Hi there,

I am trying to find out what the meaning of || is and how I am able to write it up on my computer when writing function scripts.

I copied the symbol from another website and it is used in this context:

if(var=="" || var2=="" {
alert("something here");
return false
}else{
return true;
}

I haven't been able to find the meaning in any of my searches.

Thanks ahead of time

BP

It's pretty much like saying "If the value of var = the value of var2."

The vertical bar is a simple that means to evaluate or equal to. There are different ways in PHP to call "equal to" functions, and that's one of them.

_Aerospace_Eng_
01-11-2012, 04:05 PM
It's pretty much like saying "If the value of var = the value of var2."

The vertical bar is a simple that means to evaluate or equal to. There are different ways in PHP to call "equal to" functions, and that's one of them.

What!? No the || is an OR logical operator. When you see in what you have there it means only one of the conditions needs to be true for that if statement to be true. To type that on your keyboard you use two pipes. It is usually the key under the backspace key, you may have to hit shift first to get it. It is also normally the backslash key.

http://www.w3schools.com/js/js_comparisons.asp

VIPStephan
01-11-2012, 05:00 PM
It is usually the key under the backspace key, you may have to hit shift first to get it. It is also normally the backslash key.

Keep in mind that there are different keyboard layouts for different languages and operating systems. For me the vertical bar is on the 7 key (with forward slash on Shift) and I have to press Option (a. k. a. Alt with the Symbol ⌥) + 7 to write it.

tracknut
01-11-2012, 05:05 PM
By the way, your code is missing a right parenthesis, if that's at all relevant to your situation :)



if(var=="" || var2=="") {

myfayt
01-11-2012, 05:32 PM
It means OR. Your code should look like this in some cases,


if ((var == "") || var2 == "") {
alert("something here");
}
else{
return true;
}

Blowpipe
01-12-2012, 12:03 PM
Hi Everyone,

Thanks for the replies, it is good to know what that symbol on the keyboard meant and also what it means in terms of Javascript.

Thank you for those who pointed out my sloppy code - leaving a ) off, even though this was just an example to better explain my question, it shows I need to pay more attention to my writing.

Thanks one final time

BP

bazz
01-12-2012, 08:15 PM
Stephan, you need a less complicated keyboard! lol

bazz

VIPStephan
01-12-2012, 10:11 PM
Stephan, you need a less complicated keyboard! lol


Haha! Actually, typing special characters (for my German keyboard layout, e. g. like , , ∂, , ™) is much simpler on Apple keyboards than on Windows/Unix type keyboards. These special characters are all on one of the regular keys and I only have to press Option or Shift+Option and the key rather than AltGr and some obscure code on the number block.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum