String对象
<script type="text/javascript"> /*
var str1 = new String("hello");
var str2 = new String("hello");
document.write("两个字符串的对象一样吗?"+(str1.toString()==str2.toString())); 创建一个字符串的方式:
方式1:
new String("字符串的内容"); 方式2:
var str = "字符串的内容"; 字符串常用的方法:
anchor() 生产锚点
blink() 为元素添加blink标签
charAt() 返回指定索引位置处的字符。
charCodeAt() 回一个整数,代表指定位置上字符的 Unicode 编码。 fontcolor() 把带有 COLOR 属性的一个 HTML <FONT> 标记放置在 String 对象中的文本两端 indexOf() 返回 String 对象内第一次出现子字符串的字符位置 italics() 把 HTML <I> 标记放置在 String 对象中的文本两端。 link() 把一个有 HREF 属性的 HTML 锚点放置在 String 对象中的文本两端。 replace() 返回根据正则表达式进行文字替换后的字符串的复制 split() 切割 Substr() 截取子串
toUpperCase() 转大写
toLowerCase 转小写
*/
document.write("第五章".anchor("five")+"<br/>");
document.write("第五章".blink()+"<br/>");
document.write("abc".charAt(1)+"<br/>");
document.write("abc".charCodeAt(1)+"<br/>"); //chatCodeAt返回的是索引值对应的字符的码值。
document.write("第六章".fontcolor("red")+"<br/>"); //fontcolor() 给字符串添加font标签,然后设置color的属性值。
document.write("abchellohehehello".indexOf("hello")+"<br/>"); //返回指定字符串第一次出现的索引值。
document.write("第五章".italics()+"<br/>"); //给文本添加一个i标签,把文本内容设置成斜体。
document.write("传智".link("http://www.itcast.cn")+"<br/>"); // 给文本添加一个a标签,
document.write("明天我们讲xml".replace("xml","DOM编程")+"<br/>"); // 给文本添加一个a标签, var str = "我们-大家-好";
var arr = str.split("-");
for(var index = 0 ; index<arr.length ; index++){
document.write(arr[index]+",");
}
document.write("<br/>");
document.write("abc".toUpperCase()+"<br/>"); //转大写
document.write("ABC".toLowerCase()+"<br/>"); //转小写 </script>
String对象的更多相关文章
- JavaScript String对象
本编主要介绍String 字符串对象. 目录 1. 介绍:阐述 String 对象的说明以及定义方式. 2. 实例属性:介绍 String 对象的实例属性: length. 3. 实例方法:介绍 St ...
- JavaScript中String对象的方法介绍
1.字符方法 1.1 charAt() 方法,返回字符串中指定位置的字符. var question = "Do you like JavaScript?"; alert(ques ...
- js实用篇之String对象
概述 String对象是JavaScript原生提供的三个包装对象之一,用来生成字符串的包装对象. var s1 = 'abc'; var s2 = new String('abc'); typeof ...
- java 创建string对象机制 字符串缓冲池 字符串拼接机制
对于创建String对象的机制,在这一过程中涉及的东西还是值得探究一番的. 首先看通过new String对象和直接赋值的方式有什么区别,看如下代码: public static void main( ...
- 原生JS:String对象详解
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- JavaScript String 对象
JavaScript String 对象 String 对象 String 对象用于处理文本(字符串). String 对象创建方法: new String(). 语法 var txt = new S ...
- js String对象中常用方法小结(字符串操作)
1.charCodeAt方法返回一个整数,代表指定位置字符的Unicode编码. strObj.charCodeAt(index) 说明: index将被处理字符的从零开始计数的编号.有效值为0到字符 ...
- Javascript中String对象的的简单学习
第十一课String对象介绍1:属性 在javascript中可以用单引号,或者双引号括起来的一个字符当作 一个字符对象的实例,所以可以在某个字符串后再加上.去调用String 对象 ...
- JavaScript中的String对象
String对象提供的方法用于处理字符串及字符. 常用的一些方法: charAt(index):返回字符串中index处的字符. indexOf(searchValue,[fromIndex] ...
- JavaScript基础13——js的string对象
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
随机推荐
- HDOJ 2117 Just a Numble(模拟除法)
Problem Description Now give you two integers n m, you just tell me the m-th number after radix poin ...
- LA 3485 Bridge
自适应辛普森公式模板. #include<algorithm> #include<iostream> #include<cstring> #include<c ...
- Java TCP服务端向客户端发送图片
/** * 1.创建TCP服务端,TCP客户端 * 2.服务端等待客户端连接,客户端连接后,服务端向客户端写入图片 * 3.客户端收到后进行文件保存 * @author Administrator * ...
- HDU 5266 pog loves szh III (线段树+在线LCA转RMQ)
题目地址:HDU 5266 这题用转RMQ求LCA的方法来做的很easy,仅仅须要找到l-r区间内的dfs序最大的和最小的就能够.那么用线段树或者RMQ维护一下区间最值就能够了.然后就是找dfs序最大 ...
- SPOJ PGCD (mobius反演 + 分块)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 题意 :求满足gcd(i , j)是素数(1 &l ...
- [Angular 2] ngrx/store
@ngrx/store builds on the concepts made popular by Redux and supercharges it with the backing of RxJ ...
- Android(java)学习笔记255:JNI之JNI概念
1. JNI是什么? java native interface (java本机接口) 比如方法声明: public final native Class<?> getClass(): ...
- Chapter 8. Introduction to multi-project builds 多工程构建介绍
Only the smallest of projects has a single build file and source tree, unless it happens to be a mas ...
- LA 6448 Credit Card Payment
[题目] 你的信用卡目前欠M元,每月的汇率是R,每月的利息要四舍五入为小数点后两位,你每月还B元,问多少月能还清. 输入 先是T代表测试数据组数 接下来T行,每行有三个实数,R,M,B每个实数小数 ...
- PHP博客小项目之知识点(1)
一.博客系统介绍 Blog.Bloger.web log(网络日志) 博客主要发布一些文章.图片:博客一般都是个人博客: 博客的文章,一般都是按照时间倒序排列: 博客,仅音译,英文名为Blogger, ...