ฟังก์ชัน parseInt() ของออบเจ็กต์ Number จะรับสตริง แปลงและคืนค่าจำนวนเต็มของรูปแบบหรือฐานที่ระบุ
ไวยากรณ์
รูปแบบการใช้งานคือดังนี้
Number.parseInt('0xF', 16);ตัวอย่าง
<html> <head> <title>ตัวอย่าง JavaScript</title> </head> <body> <script type="text/javascript"> var result = Number.parseInt('0xF', 16); document.write(result); </script> </body> </html>ผลลัพธ์
15