get the last character
JavaScript performance comparison
Preparation code
<script>
function charAt(s) {
return s.charAt(s.length - 1) === '#';
}
function regex(s) {
return /#$/.test(s);
}
var POUND_END_RE = /#$/;
function regex_cache(s) {
return POUND_END_RE.test(s);
}
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
charAt |
|
pending… |
regex |
|
pending… |
regex_cache |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by lifesinger
- Revision 2: published
2 comments
We wanna know why.
Why its doing like that only.. does he has anything more then that???
Thanks!