# JavaScript | How to assign decimal, octal and hexadecimal values to the variables?

Assigning decimal, octal and hexadecimal values to the variables: Here, we are going to learn how can we assign integer values in different format like decimal, octal and hexadecimal to the variables in JavaScript?
Submitted by IncludeHelp, on February 01, 2019

## JavaScript - Assign decimal, octal and hexadecimal values to the variables

Just like C programming language, we can assign integer value in the different format to the variable.

• Assigning decimal value: It can be assigned simply without using any prefix.
• Assigning octal value: It can be assigned by using 0 (zero) prefix with the octal value.
• Assigning hexadecimal value: It can be assigned using 0x or 0X prefix with the hexadecimal value.

## Example to assign decimal, octal and hexadecimal values to the variables

In the given example, we assign assigning 10 which is in decimal format to the variable a, octal format value 012 which is octal of 10 to the variable b, and hexadecimal format value 0x0A which is a hexadecimal value of 10 to the variable c, and printing all values those will be printed in decimal formats.

```<html>
<title>JavaScipt Example</title>

<body>
<script>
var a = 10; //decimal value
var b = 012; //octal value
var c = 0x0A; //hexadecimal value

//printing values
document.write("a = " + a + "<br>");
document.write("b = " + b + "<br>");
document.write("c = " + c + "<br>");
</script>
</body>
</html>
```

Output

```a = 10
b = 10
c = 10
```