首页 技术 正文
技术 2022年11月16日
0 收藏 794 点赞 4,973 浏览 1358 个字

那几个函数的应用:

<script>
//全局变量删不掉,而全局属性能删掉
var a=123;
function aa () {
b=321;
delete b;
}
aa();
delete a;
//console.log(a);var str="wo ai sanmei";
/*构造函数模式*/
function strobj (argument) {
this.concats=function (argument) {
arguments[0].concat(arguments[1]);
console.log(arguments[1].concat(arguments[0]));
};
this.indexOfs=function (argument) {
console.log(arguments[0].indexOf("o"));
};
this.lastIndexOfs=function (argument) {
console.log(arguments[0].indexOf("o"));
};this.trims=function (argument) {
console.log(arguments[0].trim().length);
};this.touppers=function (argument) {
console.log(arguments[0].toUpperCase());
};
this.toLowers=function (argument) {
console.log(arguments[0].toLowerCase());
};
}
strobj.prototype.slices = function(argument) {
console.log(arguments[0].slice(0,5));
};
strobj.prototype.substrs = function(first_argument) {
console.log(arguments[0].substr(0,4));
};
strobj.prototype.substrings = function(first_argument) {
console.log(arguments[0].substring(0,6));
};/*String*/
//charAt() charCodeAt()console.log(str.charAt(0));
console.log(str.charCodeAt(0));//字符串的连接 concat(),很多其它情况下用加号更方便
var str1='lio';
var li=new strobj();//concat连接
li.concats(str,str1);
//slice剪切
li.slices(str);
//substr从第几个选几个
li.substrs(str);
//substring从第几个究竟几个
li.substrings(str);//indexOf字符位置
li.indexOfs(str);
//lastIndexOf
li.lastIndexOfs(str);//trim 删除空格
li.trims(" Lio ai sanmei ");//大写和小写转换
li.touppers(str);
li.toLowers(str);//字符串匹配</script>

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,112
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,585
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,431
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,203
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,838
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,922