Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7519777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:57:31+00:00 2026-05-30T01:57:31+00:00

how a code var charCode = (evt.which) ? evt.which : event.keyCode could be explaned?

  • 0

how a code var charCode = (evt.which) ? evt.which : event.keyCode could be explaned?
what happens here ?
all i understand is that clause returns buttons value to the object charCode.
but what those ? and : signs mean?
and can i use this thing in other languager? java/c++/php and so on?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:57:32+00:00Added an answer on May 30, 2026 at 1:57 am

    It’s called the ternary conditional operator. It’s basically short for an if...else:

    var charCode;
    if(evt.which) {
        charCode = evt.which;
    }
    else {
        charCode = evt.keyCode;
    }
    

    Basically, it evaluates the first operand. If that evaluation returns true, the second operand is returned. If false, the third is returned.

    As for whether you can use it in other languages, you often can. From the languages you listed, Java and PHP both have it, and I’d be very surprised if C++ didn’t (edit – a quick Google reveals that C and C++ do indeed support it too). For more, see Wikipedia.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see code like this all over the web var days= Monday Tuesday Wednesday
The code: var newSelect=document.createElement('select'); index=0; var optn = document.createElement(option); //langArray is an array that
Here's some C# code: var sb = new StringBuilder(); var w = XmlWriter.Create(sb); w.WriteStartElement(hello);
my code like this function Tab(e) { var input = e.keyCode ? e.keyCode :
here is javascript code: var test = { h : function (a) {return a;},
I have this jQuery code: var thumb = $($('#slider').children('.ui-slider-handle')); setLabelPosition(); $('#slider').bind('slide', function (event, ui)
Code: var result = db.rows.Take(30).ToList().Select(a => AMethod(a)); db.rows.Take(30) is Linq-To-SQL I am using ToList()
See code: var file1 = 50.xsl; var file2 = 30.doc; getFileExtension(file1); //returns xsl getFileExtension(file2);
for example this code var html = <p>This text is <a href=#> good</a></p>; var
Suppose I have this code: var myArray = new Object(); myArray["firstname"] = "Bob"; myArray["lastname"]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.