Remove Last Comma string in javascript

Today, We want to share with you Remove Last Comma string in javascript.
In this post we will show you Remove Last Comma from String in javascript, hear for JavaScript: Remove last character from string we will give you demo and example for implement.
In this post, we will learn about Trim First/Last Characters in String in javascript with an example.

Remove Last Comma string in javascript

There are the Following The simple About Remove Last Comma string in javascript Full Information With Example and source code.

Read Also:  jQuery Remove Item From Comma Separated string

As I will cover this Post with live Working example to develop javascript – Remove Last Comma from a string, so the some major files and Directory structures for this example is following below.

  • index.html

Remove last comma from string javascript


This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.html.

Read Also:  Remove Last Character from String jQuery

//Using substring
var myStrNum = "692,9898,";

document.write(myStrNum.substring(0, myStrNum.length - 1));

//Using slice
document.write("692,9898,".slice(0, -1));

//Using map
<script src=""></script>

var myStrNum = "692,9898,";

var arrData = myStrNum.split(',');

document.write($.map(arrData, function(value, i) {
  return value != "" ? value : null;

Remove Last Character

javascript Remove Last Character Of A String

var inpValue = "JavaScript";
var results = inpValue.substr(0, inpValue.length - 4);

// Result is now "JavaSc"

var inpValue = "JavaScript";
var results = inpValue.substr(2);

// Result is now "vaScript"

Angular 6 CRUD Operations Application Tutorials
jquery remove last comma from Array
jquery remove last comma from Array

Read :

Read Also:  Secure Login System with PHP and MySQLi - login page in php


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about remove last comma from string javascript.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Laravel 7 jQuery Ajax Request Tutorial
  2. Read Also:  Laravel 6 Eloquent WHERE Like query Example
  3. Read Also:  Find all ASP.NET loop through controls on Form Clear of specific type
  4. Read Also:  Angular check ngIf Array is Empty/isset/Null
  5. Read Also:  Create Add/Remove Multiple Dynamically Input Fields in Javascript or Jquery
  6. Read Also:  Laravel Route Optional Parameters
  7. Read Also:  Simple Multiple Countdown timers using jquery
  8. Read Also:  How to get current URL in jQuery?
  9. Read Also:  How to remove comma from the string in javascript?
  10. Read Also:  How to Make Async Requests in PHP