You can use the substring function:
let str = "12345.00";
str = str.substring(0, str.length - 1);
console.log(str);
This is the accepted answer, but as per the conversations below, the slice syntax is much clearer:
let str = "12345.00";
str = str.slice(0, -1);
console.log(str);
This article about Javascript Strict Mode might interest you: John Resig - ECMAScript 5 Strict Mode, JSON, and More
To quote some interesting parts:
Strict Mode is a new feature in ECMAScript 5 that allows you to place a program, or a function, in a "strict" operating context. This strict context prevents certain actions from being taken and throws more exceptions.
And:
Strict mode helps out in a couple ways:
- It catches some common coding bloopers, throwing exceptions.
- It prevents, or throws errors, when relatively "unsafe" actions are taken (such as gaining access to the global object).
- It disables features that are confusing or poorly thought out.
Also note you can apply "strict mode" to the whole file... Or you can use it only for a specific function (still quoting from John Resig's article):
// Non-strict code...
(function(){
"use strict";
// Define your library strictly...
})();
// Non-strict code...
Which might be helpful if you have to mix old and new code ;-)
So, I suppose it's a bit like the "use strict"
you can use in Perl (hence the name?): it helps you make fewer errors, by detecting more things that could lead to breakages.
Strict mode is now supported by all major browsers.
Inside native ECMAScript modules (with import
and export
statements) and ES6 classes, strict mode is always enabled and cannot be disabled.
Best Solution
Really, you'll be fine with any of the major ones because they all can accomplish basically the same things and most have a lot of plugins and scripts that overlap. That said, I'd recommend either jQuery or MooTools.
jQuery - Large community. Very fast with latest update. Very easy for beginners. Lots of plugins.
MooTools - A little harder for beginners, but I really like its class-like structure and modularity. You can choose which parts of the framework you need and disregard the rest. The community isn't as good as jQuery's. Lots of plugins.
You'd also be fine with Prototype/Scriptaculous, YUI, Dojo, and a few others, though I'm not as familiar with their pros and cons.
An important thing to keep in mind, though, is not to use more than one library at a time. You can't use Mootools and Prototype together, but you shouldn't use the others together either because you're just unnecessarily adding to the page size. If you find a script you really like in one library, chances are that it exists in another.
You'll also get the best compression by gzipping your files when you serve them to the browser.