Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

แปลง String เป็น Lowercase ด้วย JavaScript

เรียนรู้วิธีแปลงข้อความทุก case เป็นตัวพิมพ์เล็ก (lowercase) ด้วย JavaScript

ใช้เมธอด toLowerCase():

let someText = "Here is some text. Let us convert it all to lowercase";
someText.toLowerCase();
console.log(someText.toLowerCase());
// here is some text. let us convert it all to lowercase

toLowerCase() คืนค่า string ใหม่ หมายความว่า ไม่ mutate (เปลี่ยน) string ต้นฉบับ