.substring() , .trim().substring() are giving me different results in JavaScript why is this happening?

Viewed 18
let val = " ulimate ,"

console.log("result 1 : ",val.substring(0 , val.length -1))
console.log("result 2 : ",val.trim().substring(0 , val.length -1))

result : 

result 1 :  ulimate 
result 2 :  ulimate ,

.substring() , .trim().substring() are giving separate results

0 Answers
Related