| length | ใช้คืนค่าความยาวของ ตัวอักษร |
|---|---|
| sup() | ใช้แสดงผลข้อความแบบตัวยก |
| sub() | ใช้แสดงผลข้อความแบบตัวห้อย |
| blink() | ใช้แสดงผลข้อความแบบ กระพริบ |
| strike() | ใช้แสดงผลข้อความแบบ มีเส้นขีดทับตัวอักษรตรงกลาง |
| bold() | ใช้แสดงผลข้อความแบบ ตัวหนา |
| italics() | ใช้แสดงผลข้อความแบบ ตัวเอียง |
| big() | ใช้กำหนดให้ขนาดของตัวอักษรใหญ่ขึ้น |
| small() | ใช้กำหนดให้ขนาดของตัวอักษรเล็กลง |
| fontsize() | ใช้กำหนดขนาดของตัวอักษร |
| fontcolor() | ใช้กำหนดสีของตัวอักษร |
| toUpperCase() | ใช้แปลงตัวอักษรเป็น ตัวพิมพ์ใหญ่ |
| toLowerCase() | ใช้แปลงตัวอักษรเป็น ตัวพิมพ์เล็ก |
| link() | ใช้กำหนดข้อความให้เป็นลิงค์ |
| charAt() | ใช้แสดงผล ตัวอักขระ ณ ตำแหน่งที่กำหนด |
| charCodeAt() | ใช้แสดงผล รหัส ascii ของตัวอักขระ ณ ตำแหน่งที่กำหนด |
| substr() | ใช้ดึงข้อความ ตั้งแต่ตำแหน่งที่กำหนด ตามจำนวนที่กำหนด |
| substring() | ใช้ดึงข้อความ ตั้งแต่ตำแหน่งที่กำหนด จนถึงตำแหน่งที่กำหนด |
| concat() | ใช้เชื่อมข้อความ เหมือนการใช้ตัวดำเนินการ "+" |
| slice() | ใช้ดึงข้อความ ตั้งแต่ตำแหน่งที่กำหนด จนถึงตำแหน่งที่กำหนด |
| localeCompare() | ใช้เปรียบเทียบ ข้อความ |
| split() | ใช้แบ่งข้อความออกเป็นส่วนๆ ตามตัวแบ่งที่กำหนด |
| indexOf() | ใช้ค้นหาข้อความจากหน้าไปหลัง โดยจะคืนค่าตำแหน่งแรกที่พบ |
| lastIndexOf() | ใช้ค้นหาข้อความจากหลังมาหน้า และเริ่มค้นหาจากตำแหน่งที่กำหนด |
property:length;
return type:number
content:ใช้คืนค่าความยาวของ ตัวอักษร
example:var str = new String ( "BambooLabcode" ); alert ( str.length );
method:sup ();
return type:string
content:ใช้แสดงผลข้อความแบบตัวยก
example:var str = new String ( "30" ); alert ( "500" + str.sup() );
method:sub ();
return type:string
content:ใช้แสดงผลข้อความแบบตัวห้อย
example:var str = new String ( "2" ); alert ( "log" + str.sub() + "10" );
method:blink ();
return type:string
content:ใช้แสดงผลข้อความแบบ กระพริบ
example:var str = new String ( "new" ); alert ( str.blink() );
method:strike ();
return type:string
content:ใช้แสดงผลข้อความแบบ มีเส้นขีดทับตัวอักษรตรงกลาง
example:var str = new String ( "Cancel" ); alert ( str.strike() );
method:bold ();
return type:string
content:ใช้แสดงผลข้อความแบบ ตัวหนา
example:var str = new String ( "W E L C O M E" ); alert ( str.bold() );
method:italics ();
return type:string
content:ใช้แสดงผลข้อความแบบ ตัวเอียง
example:var str = new String ( "Comment" ); alert ( str.italics() );
method:big ();
return type:string
content:ใช้กำหนดให้ขนาดของตัวอักษรใหญ่ขึ้น
example:var str = new String ( "Welcome" ); alert ( str.big() );
method:small ();
return type:string
content:ใช้กำหนดให้ขนาดของตัวอักษรเล็กลง
example:var str = new String ( "Welcome" ); alert ( str.small() );
method:fontsize ( int );
return type:string
content:ใช้กำหนดขนาดของตัวอักษร
example:var str = new String ( "Welcome" ); alert ( str.fontsize( 20 ) );
method:fontcolor ( value_color );
return type:string
content:ใช้กำหนดสีของตัวอักษร
example:var str = new String ( "Welcome" ); alert ( str.fontcolor( "blue" ) );
method:toUpperCase ();
return type:string
content:ใช้แปลงตัวอักษรเป็น ตัวพิมพ์ใหญ่
example:var str = new String ( "welcome" ); alert ( str.toUpperCase() );
method:toLowerCase ();
return type:string
content:ใช้แปลงตัวอักษรเป็น ตัวพิมพ์เล็ก
example:var str = new String ( "WELCOME" ); alert ( str.toLowerCase() );
method:link ( web_page );
return type:string
content:ใช้กำหนดข้อความให้เป็นลิงค์
example:var str = new String ( "bamboolabcode" ); document.write ( str.link( "http://www.bamboolabcode.com" ) );
method:charAt ( index );
return type:string
content:ใช้แสดงผล ตัวอักขระ ณ ตำแหน่งที่กำหนด
example:var str = new String ( "bamboolabcode" ); alert ( str.charAt ( 2 ) );
method:charCodeAt ( index );
return type:number
content:ใช้แสดงผล รหัส ascii ของตัวอักขระ ณ ตำแหน่งที่กำหนด
example:var str = new String ( "bamboolabcode" ); alert ( str.charCodeAt ( 2 ) );
method:substr ( start, length );
return type:string
content:ใช้ดึงข้อความ ตั้งแต่ตำแหน่งที่กำหนด ตามจำนวนที่กำหนด
example:var str = new String ( "bamboolabcode" ); alert ( str.substr ( 5, 6 ) );
method:substring ( start, stop );
return type:string
content:ใช้ดึงข้อความ ตั้งแต่ตำแหน่งที่กำหนด จนถึงตำแหน่งที่กำหนด
example:var str = new String ( "bamboolabcode" ); alert ( str.substring ( 0, 5 ) );
method:concat ( string );
return type:string
content:ใช้เชื่อมข้อความ เหมือนการใช้ตัวดำเนินการ "+"
example:var str1 = new String ( "bamboo" ); var str2 = new String ( "labcode" ); alert ( str1.concat ( str2 ) );
method:slice ( start, stop );
return type:string
content:ใช้ดึงข้อความ ตั้งแต่ตำแหน่งที่กำหนด จนถึงตำแหน่งที่กำหนด
example:var str = new String ( "bamboolabcode" ); alert ( str.slice ( 0, 5 ) );
method:localeCompare ( string );
return type:number
content:ใช้เปรียบเทียบ ข้อความ
example:var str1 = new String ( "ManUtd" ); var str2 = new String ( "ManCity" ); alert ( str1.localeCompare ( str2 ) );
comment:คืนค่า -1 แสดงว่า string1 < string2 คืนค่า 0 แสดงว่า string1 = string2 คืนค่า 1 แสดงว่า string1 > string
method:split ( separator );
return type:array
content:ใช้แบ่งข้อความออกเป็นส่วนๆ ตามตัวแบ่งที่กำหนด แล้วเก็บไว้ที่ array object
example:var str = new String ( "bamboo, labcode, panda" ); var arr = str.split ( ", " );
method:indexOf ( search, start );
return type:number
content:ใช้ค้นหาข้อความจากหน้าไปหลัง และเริ่มค้นหาจากตำแหน่งที่กำหนด โดยจะคืนค่าตำแหน่งแรกที่พบ
example:var str = new String ( "bamboolabcode" ); alert ( str.indexOf ( "o", 6 ) );
comment:จะคืนค่า -1 ถ้าไม่พบข้อความที่ค้นหา
method:lastIndexOf ( search, start );
return type:number
content:ใช้ค้นหาข้อความจากหลังมาหน้า และเริ่มค้นหาจากตำแหน่งที่กำหนด โดยจะคืนค่าตำแหน่งแรกที่พบ
example:var str = new String ( "bamboolabcode" ); alert ( str.lastIndexOf ( "a", 6 ) );
comment:จะคืนค่า -1 ถ้าไม่พบข้อความที่ค้นหา