4

Possible Duplicate:
How to convert decimal to hex in JavaScript?

Is there an equivalent of python's int('hex-string', 16) function in Javascript?

2
  • yourNumber = parseInt(hexString, 16); Commented Oct 28, 2011 at 16:45
  • Sorry for the duplicate. Commented Oct 28, 2011 at 17:49

1 Answer 1

7

You can use parseInt():

var result = parseInt("0x42", 16);  // 66
Sign up to request clarification or add additional context in comments.

1 Comment

If you place 0x you may omit radix: parseInt("0x42")

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.