
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
HTML5 data-* attribute type casting strings and numbers
For data-attribute typecasting of Numbers and String, use −
[...document.querySelectorAll("a")].forEach(a => console.log("type: %s, value: %o", typeof a.dataset.value, a.dataset.value) );
The above is for the following data-attributes −
<a data-value = "6.0">6.0</a> <a data-value = "6.5">6.5</a>
- Related Articles
- Difference Between Type casting and Type Conversion
- Java Type Casting Examples
- Type casting in JavaScript.
- Type Casting operators in C++
- HTML5 preload attribute
- Explicit type casting operator in C++
- What is Type casting in C#?
- Explicit Type Casting in Python Language
- const_cast in C++ - Type casting operators
- What is the difference between type conversion and type casting in C#?
- Return True if cast between scalar and data type can occur according to the casting rule in Python
- Best data type for storing large strings in MySQL?
- Return True if cast between array scalar and data type can occur according to the casting rule in Python
- Usage of autofocus HTML5 attribute
- Composition attribute in HTML5 Canvas?

Advertisements