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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:46:48+00:00 2026-05-26T02:46:48+00:00

!! always works fine for converting String , undefined , Object and Number types

  • 0

!! always works fine for converting String, undefined, Object and Number types to Boolean type in JavaScript:

!!0           // false
!!1           // true
!!10          // true
!!""          // true
!!"any"       // true
!!undefined   // false
!!null        // false
!!NaN         // false
!!{}          // true

It seems using !! is totally safe. I’ve seen people using this for converting variables.

But I’m not sure about ++ or -- for converting String types to Number types. In these examples it looks using ++ for converting is safe:

var ten = "10";
ten++  // 10

var nineHalf = "9.5";
nineHalf++ // 9.5

var n = "-10.06";
n++ // -10.06

Is there any case that ++/-- don’t work as parseFloat?

  • 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-26T02:46:49+00:00Added an answer on May 26, 2026 at 2:46 am

    Just use a single + (unary plus operator). It is a common practice just like !! for booleans.

    (+"10.06")
    

    The ++ version makes me afraid of the increment operators doing evil tricks when I’m not looking.


    Edit: And of course, the postIncrement operator doesn’t even work on string literals.

    "10.06"++  //syntax error
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the following js works fine in FF2 but in IE6 the dropdown always selects
As the title says: What's best way of converting a string from any-case to
How to make VIM to always auto-complete filenames in command mode? It works fine
In my Javascript I am manually calling __doPostBack('myUpdatePanelId','mycustomeventarg') It works fine except the EventArgs
This code works fine in SQL 2005 but appears to miss a random number
One of the services works fine but the other always throws a Socket Timeout
I have a JQuery slider which works fine in all browsers except IE(always a
This code always works, even in different browsers: function fooCheck() { alert(internalFoo()); // We
I've always been confused about how the linker works, and it's a difficult subject
When I run this code: >> I = imread('D:\Works\matlab\SecCode.php.png','png'); >> imshow(I); It always shows

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.