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 8086463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:27:19+00:00 2026-06-05T18:27:19+00:00

Possible Duplicate: Is it safe to assume strict comparison in a Javascript switch statement?

  • 0

Possible Duplicate:
Is it safe to assume strict comparison in a Javascript switch statement?

Does a switch/case statement in javascript compare types or only values?

In other words, when I have the following code:

switch (variable)
{
    case "0": [...] break;
    case "1": [...] break;
    default: [...] break;
}

is it equivalent to

if ( variable == "0" )
{
    [...]
}
else if ( variable == "1" )
{
    [...]
}
else
{
    [...]
}

or to

if ( variable === "0" )
{
    [...]
}
else if ( variable === "1" )
{
    [...]
}
else
{
    [...]
}

edit: is there a way to force compare values and types at once?

  • 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-06-05T18:27:21+00:00Added an answer on June 5, 2026 at 6:27 pm

    Yes, types are compared.

    If input is equal to clauseSelector as defined by the === operator,
    then set found to true.

    ECMA-262, page 95.

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

Sidebar

Related Questions

Possible Duplicate: In C# is a for(;;) safe and what does it really do?
Possible Duplicate: FAQ: Why does dynamic_cast only work if a class has at least
Possible Duplicate: What is the most efficient way to clone a JavaScript object? (Most
Possible Duplicate: oracle PL/SQL: sort rows I run this query: Select a.product, sum( case
Possible Duplicate: Javascript window resize event I want to get an event which is
Possible Duplicates: Is it reasonable to assume my visitors have javascript enabled? How many
Possible Duplicate: Malloc thread-safe? I am not a bit confused while I am reading
Possible Duplicate: Is it safe for structs to implement interfaces? Take this code: interface
Possible Duplicate: .NET Controls: Why aren’t all calls thread-safe? This question is not about
Possible Duplicate: Are C# arrays thread safe? I have been programming C# for 10

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.