| parseInt() | ใช้แปลงชนิดข้อมูลให้เป็นเลขจำนวนเต็ม |
|---|---|
| parseInt() | ใช้แปลงเลขฐานจากฐาน 2, 8, 10, 16 ให้เป็นเลขฐาน 10 |
| parseFloat() | ใช้แปลงชนิดข้อมูลให้เป็นเลขจำนวนจริง |
| isNan() | ใช้ตรวจสอบว่า object ที่กำหนดไม่ใช่ตัวเลข ใช่หรือไม่ |
| isFinite() | ใช้ตรวจสอบว่า object ที่กำหนด ค่าข้อมูลมีสิ้นสุด ใช่หรือไม่ |
| eval() | ใช้ประมวลผลคำสั่ง javascript |
| escape() | ใช้ในการเข้ารหัส ascii |
| unescape() | ใช้ในการถอดรหัส ascii |
| encodeURI() | ใช้ในการเข้ารหัส URI ที่เป็นช่องว่าง |
| decodeURI() | ใช้ในการถอดรหัส URI ที่เป็นช่องว่าง |
| encodeURIComponent() | ใช้ในการเข้ารหัส URI ที่เป็นช่องว่าง และอักขระพิเศษ |
| decodeURIComponent() | ใช้ในการถอดรหัส URI ที่เป็นช่องว่าง และอักขระพิเศษ |
function:parseInt ( object );
return type:number
content:ใช้แปลงชนิดข้อมูลให้เป็นเลขจำนวนเต็ม ( Number ) โดยการทำงานของ method นี้ คือ จะตรวจสอบค่าทีละตำแหน่งตั้งแต่ตำแหน่งแรก และจะหยุดเมื่อเจอค่าที่ไม่ใช่ตัวเลขหรือหมดครบทุกตำแหน่ง แล้วจะคืนค่าตัวเลขกลับมา ยกเว้นถ้าตำแหน่งแรกไม่ใช่ตัวเลขจะคืนค่า NaN กลับมา ( NaN ย่อมาจาก Not a Number )
example:alert ( parseInt( "108.19" ) ); alert ( parseInt( "0xB" ) ); alert ( parseInt( "ok" ) );
function:parseInt ( object, เลขฐาน );
return type:number
content:ใช้แปลงเลขฐานจากฐาน 2, 8, 10, 16 ให้เป็นเลขฐาน 10 โดยให้ระบุไว้ด้วยว่า ค่าข้อมูลนั้นเป็นเลขฐานอะไรอยู่ แล้วจึงแปลงเป็นเลขฐาน 10
example:alert ( parseInt( "111", 2 ) ); alert ( parseInt( "111", 8 ) ); alert ( parseInt( "111", 10 ) ); alert ( parseInt( "AF", 16 ) );
function:parseFloat ( object );
return type:number
content:ใช้แปลงชนิดข้อมูลให้เป็นเลขจำนวนจริง ( RealNumber ) โดยการทำงานของ method นี้ คือ จะตรวจสอบค่าทีละตำแหน่งตั้งแต่ตำแหน่งแรก และจะหยุดเมื่อเจอค่าที่ไม่ใช่ตัวเลขหรือหมดครบทุกตำแหน่ง แล้วจะคืนค่าตัวเลขกลับมา ยกเว้นถ้าตำแหน่งแรกไม่ใช่ตัวเลขจะคืนค่า NaN กลับมา ( โดยเมธอดนี้ยอมรับค่าทศนิยม แต่ไม่ยอมรับเลขฐานอื่นๆนอกจากเลขฐาน 10 )
example:alert ( parseFloat ( "108.19" ) ); alert ( parseFloat ( "0xB" ) ); alert ( parseFloat ( "ok" ) );
function:isNan ( object );
return type:boolean
content:ใช้ตรวจสอบว่า object ที่กำหนดไม่ใช่ตัวเลข ใช่หรือไม่ ( NaN ย่อมาจาก Not a Number )
example:if ( isNan ( "bamboo" ) ) { alert ( "not a number" ); }
function:isFinite ( object );
return type:boolean
content:ใช้ตรวจสอบว่า object ที่กำหนด ค่าข้อมูลมีสิ้นสุด ใช่หรือไม่
example:if ( isFinite ( "123" ) ) { alert ( "have a limit" ); }
function:eval ( string );
return type:void
content:ใช้ประมวลผลคำสั่ง javascript
example:eval ( "var num = 500 * 10;" ); alert ( num );
function:escape ( string );
return type:string
content:ใช้ในการเข้ารหัส ascii
example:var str = new String ( "BambooLabcode" ); alert ( escape ( str ) );
function:unescape ( string );
return type:string
content:ใช้ในการถอดรหัส ascii
example:var str = new String ( "BambooLabcode" ); var coder = escape ( str ); alert ( unescape ( coder ) );
function:encodeURI ( string );
return type:string
content:ใช้ในการเข้ารหัส URI ที่เป็นช่องว่าง ( URI ย่อมาจาก Uniform Resource Identifiers )
example:alert ( encodeURI ( "http://www.bamboolabcode.com" ) );
function:decodeURI ( string );
return type:string
content:ใช้ในการถอดรหัส URI ที่เป็นช่องว่าง ( URI ย่อมาจาก Uniform Resource Identifiers )
example:var coder = encodeURI ( "http://www.bamboolabcode.com" ); alert ( decodeURI ( coder ) );
function:encodeURIComponent ( string );
return type:string
content:ใช้ในการเข้ารหัส URI ที่เป็นช่องว่าง และอักขระพิเศษ ( URI ย่อมาจาก Uniform Resource Identifiers )
example:alert ( encodeURIComponent ( "http://www.bamboolabcode.com" ) );
function:decodeURIComponent ( string );
return type:string
content:ใช้ในการถอดรหัส URI ที่เป็นช่องว่าง และอักขระพิเศษ ( URI ย่อมาจาก Uniform Resource Identifiers )
example:var coder = encodeURI ( "http://www.bamboolabcode.com" ); alert ( decodeURIComponent ( coder ) );