4

I can't seem to find out what "~=" does in JavaScript. I was look at this tutorial and I saw that. I couldn't figure out what the symbol is called so if they asked this already, please tell me and I'll delete this post, thanks in advance. The specific line is:

window.requestAnimationFrame(function(/* time */ time){ 
  // time ~= +new Date // the unix time 
});
clancer
  • 613
  • 4
  • 10
  • Nope because that one is different, I know that one is a bitwise operator but what does it do with the equal sign –  Mar 05 '14 at 00:04
  • But then what is it with the equal sign? –  Mar 05 '14 at 00:06
  • @androidmaster what is `+` with the `=` sign? – Pointy Mar 05 '14 at 00:06
  • Guys if it is a duplicate please don't -rep, I'll just delete it, please dont do -rep since then I wont be able to ask more questions –  Mar 05 '14 at 00:07
  • 1
    Please show code in the question. Then we'll have a chance. There is no ~= operator in Javascript unless I'm mistaken. – David Heffernan Mar 05 '14 at 00:07
  • I dont think thats a valid javascript operator... though in pseudo code you might use it to say approximately equal to – clancer Mar 05 '14 at 00:08
  • + with the = sign is += which adds onto the number –  Mar 05 '14 at 00:08
  • I saw in the tutorial, scroll down where it saids `window.requestAnimationFrame(function(/* time */ time){ // time ~= +new Date // the unix time` }); –  Mar 05 '14 at 00:08
  • No. Put it in the question. Off site links are no good. – David Heffernan Mar 05 '14 at 00:10
  • Yes but its commented out in the tutorial so it might just be shorthand for approximately equal to... while not being valid javascript – clancer Mar 05 '14 at 00:10
  • Okay, shall I delete this post or leave it? –  Mar 05 '14 at 00:10
  • Why did i get -1 oh no i have only one 1 left to ask before i get banned –  Mar 05 '14 at 00:14
  • Thank you who ever donated rep, I will forever admire you –  Mar 05 '14 at 00:15
  • 1
    `var t = 5; t ~= 100;`: `SyntaxError: Unexpected token ~`. So the answer to your question is: It does nothing because it's a syntax error. – Felix Kling Mar 05 '14 at 01:32
  • Thanks shouldn't that be the an answer –  Mar 05 '14 at 13:03

0 Answers0