当前位置: 首页 > 网络学院 > 客户端脚本教程 > 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   浏览: 727 ::
收藏到网摘: n/a

The String object is used to manipulate a stored piece of text.
字符串对象被用来操作存储的文字片段


Examples举例

Return the length of a string
How to use the length property to find the length of a string.
怎样使用length(长度)属性来得出一串字符的长度

Style strings
How to style strings.
样式化字符串

The indexOf() method
How to use the indexOf() method to return the position of the first occurrence of a specified string value in a string.
怎样使用indexOf()方法来返回第一次出现一指定字符串的位置数。

The match() method
How to use the match() method to search for a specified string value within a string and return the string value if found
怎样使用match()方法寻找一指定的字符串值如果找到的话就返回其值(没的有话就返回NULL)

Replace characters in a string - replace()
How to use the replace() method to replace some characters with some other characters in a string.
怎样使用replace()方法来用一些其他字符替换字符串中的一些字符

Tip: You will find a lot more examples in the String object reference - look at the bottom of this page!
提示:你将在String object reference(字符串对象参考)找到更多的例子!


String object
字符串对象

The String object is used to manipulate a stored piece of text.
用来操作被存储的文字片段

Examples of use:
使用实例:

The following example uses the length property of the String object to find the length of a string:
下面的例子使用了长度属性来找出字符串的长度:

var txt="Hello world!"
document.write(txt.length)

The code above will result in the following output:
上面的代码的结果为下:

12

The following example uses the toUpperCase() method of the String object to convert a string to uppercase letters:
下面的例子使用了toUpperCase()方法来让字符串对象的内容转换为大写字母:

var txt="Hello world!"
document.write(txt.toUpperCase())

The code above will result in the following output:
上面的代码将有下面的结果:

HELLO WORLD!

Complete String Object Reference
完整的字符串对象参考

For a complete reference of all the properties and methods that can be used with the String object, go to our complete String object reference.
查看完整的字符串对象参考

The reference contains a brief description and examples of use for each property and method!
参考里有怎样使用属性和方法的举例和描述

评论 (0) All

登陆 | 还没注册?