Click here to Skip to main content
15,914,014 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Just a quick question guys, anyone knows the meaning for this symbol '^' in js ?

JavaScript
function myFunction()
{
var str = "";
var n = 2 ^ 50 ;
document.getElementById("demo").innerHTML=n;
}
</script>


Got the result 48 why ?
Posted
Updated 24-Nov-13 12:12pm
v2
Comments
Sergey Alexandrovich Kryukov 24-Nov-13 18:04pm    
Why would you ever write some code using some operator, if you don't know its meaning?
And what's wrong with just reading Java documentation?

And who told you this code is Java? It can be Javascript, which has nothing to do with Java. Please don't tell us "I know it's Javascript". Not quite. Just mentioning "Java" is enough to see it.

You don't even know the name of the language of the name you are writing in, forget about the language knowledge itself. Let me ask you: why writing anything at all then? Just to waste your and our time? You got a big fat vote of 1 here, sorry.

—SA
nazarinlaw 24-Nov-13 18:08pm    
Im not familiar with javascript, just need them converted to use with my net project !
Sergey Alexandrovich Kryukov 24-Nov-13 18:09pm    
Get familiar first, at least know the name of the language. Read some manual, try to write code, then ask your questions.
—SA
nazarinlaw 24-Nov-13 18:08pm    
If you don't help me , fine just don't spam !
Sergey Alexandrovich Kryukov 24-Nov-13 18:11pm    
The spam is yours, not mine. I am helping you to make a serious decision: stop being lazy and start using your brain; and this is the most important help you need. If you don't want it and want to be rude instead, who is the looser? and anyway, you should stop spamming the site, because helping people with such attitude is useless.

Good luck,
—SA

1 solution

Its a Bitwise XOR operator. Please have a look at below link for more Bitwise operators.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators


Have a look at online Bitwise operator calculator.

http://www.miniwebtool.com/bitwise-calculator/?data_type=10&number1=2&number2=50&operator=XOR
 
Share this answer
 
v2
Comments
nazarinlaw 24-Nov-13 16:45pm    
Thanks alot !
RaisKazi 24-Nov-13 16:55pm    
Welcome, :)
nazarinlaw 24-Nov-13 17:37pm    
Hi bro just a few more doubts about this booleon function in js

e == 64 ? j[h++] = String.fromCharCode(b) : f == 64 ? j[h++] = String.fromCharCode(b, c) : j[h++] = String.fromCharCode(b, c, d);

i hardly can't understand this, and also i want to convert into .NET.
RaisKazi 24-Nov-13 22:09pm    
Its Ternary Operator. And whats the reason you Accepted answer and then unaccepted it?
http://msdn.microsoft.com/en-us/library/ie/be21c7hw(v=vs.94).aspx
Sergey Alexandrovich Kryukov 25-Nov-13 11:14am    
Maybe you could understand it if you also look at the comments to the question, to get an idea who are you talking to... :-(
From me, a 5 for the answer, by the way... :-)
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900