1

I have seen jQuery code's like this

 return 13 == t.keyCode ? (t.preventDefault(), !1) : void 0

What that mean for ? and : ?

Please give me reference, because I still newbie in jQuery. Thank's a lot

dedi wibisono
  • 439
  • 4
  • 10
  • 22
  • 3
    Read [this](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) – Dhaval Marthak Feb 07 '17 at 06:18
  • its shorthand style of writing if else – Akshay Feb 07 '17 at 06:18
  • 3
    This is not jQuery. It's JavaScript syntax. – Parvez Rahaman Feb 07 '17 at 06:19
  • Be sure to know the difference between jQuery and Javascript. Javascript is what the browser understands. jQuery is written in Javascript, and is "just" a library to make a lot of commonly used design patterns in web design easier. Try to understand the basics of Javascript before dabbling in jQuery, otherwise you might run into more problems like these. – Jeff Huijsmans Apr 13 '17 at 16:05

2 Answers2

2

It is a shorthand for if else:

Translation:

if(13 == t.keyCode) { return (t.preventDefault(), !1); } else { return void 0; }
Niels Vermeiren
  • 218
  • 3
  • 10
2

Its ternary operator. Shorthand for writting if/else

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

Parth Ghiya
  • 6,401
  • 2
  • 27
  • 35