当前位置: 首页 > 网络学院 > 客户端脚本教程 > JavaScript > JS 对象实例

JavaScript
JS 字符串
JS Date
JS数组,JS Array
JS Boolean
JS Math
JS HTML DOM
JS Browser
JS Cookies
JS 校验
JS Animation
JS Image Maps
JS Timing
JS 建立对象
JS 摘要
JS 实例
JS 对象实例
JS DOM 实例
JS数组对象参考
JS布尔对象参考
JS日期对象参考

JavaScript 中的 JS 对象实例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 1201 ::
收藏到网摘: n/a

Examples of using the built-in JavaScript objects.
使用内置对象的实例


String Object
字符串对象

Return the length of a string
返回字符串长度
Style strings
字符串样式
Return the position of the first occurrence of a text in a string - indexOf()
返回文字在字符串中首次出现的位置 - indexOf()
Search for a text in a string and return the text if found - match()
查找字符串中的文字如果找到则返回文字 - match()
Replace characters in a string - replace()
替换字符串中的文字 - replace()

More String object examples in our JavaScript reference.
更多字符串对象举例在我们的JS参考中

Date Object
日期对象

Use Date() to return today's date and time
使用Date()返回今天的日期和当前时间
Use getTime() to calculate the years since 1970
使用getTime()来计算从1970到现在用了多少时间
Use setFullYear() to set a specific date
使用setFullYear()来设置指定日期
Use toUTCString() to convert today's date (according to UTC) to a string
使用toUTCString()将今天的日期转(根据UTC,国际时间)换成字符串
Use getDay() and an array to write a weekday, and not just a number
使用getDay和数组来输出周日,而不是简单的数字
Display a clock
显示时钟

More Date object examples in our JavaScript reference.
在我们的JS参考中有更多日期对象举例

Array Object
数组对象

Create an array
建立数组
Use a for…in statement to loop through the elements of an array
使用 for...in生命来循环数组中的元素
Join two arrays - concat()
将两个数组结合 - concat()
Put array elements into a string - join()
将数组放入字符串中 - join()
Literal array - sort()
按字母大小排列数组 - sort()
Numeric array - sort()
按数字大小排列数组 - sort()

More Array object examples in our JavaScript reference.
在我们的JS参考中有更多数组对象方面的举例

Boolean Object
布尔对象

Check Boolean value
检查布尔值

More Boolean object examples in our JavaScript reference.
在我们的JS参考中有更多有关布尔对象的举例

Math Object
数学对象

Use round() to round a number
使用round()来四舍五入数字
Use random() to return a random number between 0 and 1
使用random()来返回一个在0到1之间的随机数
Use max() to return the number with the highest value of two specified numbers
使用max()来返回指定数字中的最高值
Use min() to return the number with the lowest value of two specified numbers
使用min()来返回指定数字中的最低值
Convert Celsius to Fahrenheit
将摄氏度转换成华氏度

More Math object examples in our JavaScript reference
在我们的JS参考中有更多有关数学对象的举例.

评论 (0) All

登陆 | 还没注册?