It always a good practice to pass radix with parseInt –
parseInt(string, radix)
For decimal –
parseInt(id.substring(id.length - 1), 10)
If the radix parameter is omitted, JavaScript assumes the following:
- If the string begins with “0x”, the radix is 16 (hexadecimal)
- If the string begins with “0”, the radix is 8 (octal). This feature is deprecated
- If the string begins with any other value, the radix is 10 (decimal)
Related Posts:
- Should I use JSLint or JSHint JavaScript validation?
- Why does JSHint throw a warning if I am using const?
- Don’t make functions within a loop [duplicate]
- How to initialize an array’s length in JavaScript?
- JSLint is suddenly reporting: Use the function form of “use strict”
- How to delete a cookie?
- ES6 Map in Typescript
- How do I color a hexagonal grid such that it doesn’t have neighbors of the same color?
- How to format a JavaScript date
- Wait 5 seconds before executing next line
- Sort array of objects by string property value
- Chrome sendrequest error: TypeError: Converting circular structure to JSON
- How to set header and options in axios?
- JavaScript equivalent to printf/String.Format
- How to read a local text file?
- Open a URL in a new tab (and not a new window)
- How do I correctly clone a JavaScript object?
- JavaScript: Upload file
- Console logging for react?
- What is the “right” JSON date format?
- Node.js – SyntaxError: Unexpected token import
- Developing an ad with MRAID.js
- ReferenceError: Invalid left-hand side in assignment
- How to detect Safari, Chrome, IE, Firefox and Opera browser?
- Javascript versioning to avoid caching, difference in these practices?
- jQuery animate backgroundColor
- JavaScript get element by name
- How do I disable right click on my web page?
- Left() function in Javascript or jQuery
- Why is “forEach not a function” for this object?
- When is JavaScript synchronous?
- How to reset a form using jQuery with .reset() method
- Uncaught ReferenceError: Firebase is not defined
- Efficient way to implement Priority Queue in Javascript?
- How do you format a Date/Time in TypeScript?
- JavaScript function in href vs. onclick
- How to scroll to an element?
- How would I call a javascript function in html?
- Javascript removeEventListener not working
- Load image with jQuery and append it to the DOM
- RGB to hex and hex to RGB
- No visible cause for “Unexpected token ILLEGAL”
- Change text on hover, then return to the previous text
- How do I include a JavaScript file in another JavaScript file?
- Understanding the ngRepeat ‘track by’ expression
- How can I test if a letter in a string is uppercase or lowercase using JavaScript?
- How to create a HTML Cancel button that redirects to a URL
- What does the construct x = x || y mean?
- Discord error cannot read property ‘isFocused’
- onClick not working React js
- How to get the first element of an array?
- How to instantiate a File object in JavaScript?
- How to change the buttons text using javascript
- How to sort in mongoose?
- “Uncaught TypeError: a.indexOf is not a function” error when opening new foundation project
- How do you serve a file for download with AngularJS or Javascript?
- How can I cache image files locally with PhoneGap / Cordova?
- how to display a div triggered by onclick event
- JavaScript: function returning an object
- What is the non-jQuery equivalent of ‘$(document).ready()’?
- Changing the selected option of an HTML Select element
- How to export JavaScript array info to csv (on client side)?
- Should I use encodeURI or encodeURIComponent for encoding URLs?
- JAX post error : Refused to set unsafe header “Connection”
- Is it Possible to Extend WP Customize JS Methods?
- What are all the query parameters for getEntityRecords?
- How to add code to just before closing body tag
- How to prevent text modified using gettext filter being stomped (presumably) by updateText() js function within a CPT’s edit screen
- WP script versioning breaks cross-site caching?
- Customizer JS API: Defining control settings
- Is there a client side API for handling transients or options?
- Using React.js in WordPress
- Updata Metadata WP Rest API
- How should I add JavaScript to a child theme?
- How to add JavaScript file using wp_enqueue_scripts?
- Custom block SelectControl works but equivalent ComboboxControl gives errors – where’s my mistake?
- Customizer JS API: Adding a “dropdown-pages” control
- wp.editor.initialize does nothing
- Enqueue Javascript After ALL Other Scripts (Including Async Scripts)
- Enqueue js script to footer
- Add A Tag To A Post Through JavaScript In Gutenberg UI?
- How to reference TinyMCE body in my script
- Load page in customizer preview on panel click?
- Implementing Webflow JS in WordPress
- This page can’t load Google Maps correctly [closed]
- Load images after page load
- Make a script work within a page
- How to stop javascript code being broken when going into visual editor
- Add JavaScript to single post
- Failing to load my script files in wordpress! i can’t figure out what i’m doing wrong
- Facebook fanbox problem
- Add Paypal button redirect to a specific page after completing
- How to load Javascript code or functions.php later in a child theme?
- wp-api Backbone JS Client fetch options
- Deferring Script wp-i18n causes a console error ‘wp is not defined’ – Gravityforms
- Can’t Listen to KeyDown in TInyMCE Iframe (jQuery) and Pass it to Parent HTML FORM
- Trying to deque some .js from source
- How to change number field to text field using JS
- How to Create a Repeatable Meta Box
- Styling parent based on a child element of a child in a WordPress page