当前位置: 首页 > 图文教程 > 网络编程 > Javascript > js不是基础的基础

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 js不是基础的基础


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

前言
Javascript是一门很自由的语言,在JS里,里面一切的东西都是变量.包括函数在内.
基础
函数
(定义)(参数1[,参数2..]) 以下代码将创建一个函数并执行它.
(function (str){alert(str.length);})('test_str');
(function (str1,str2){alert(str1 str2);})('str1111','str2222');
http://vc.wz:80/l.html?q=5&b=5#ddd
下面第一个字段(字段用空格分割)是window.location的其中一个属性,后面是它的值。
hash #ddd
host vc.wz:80
hostname vc.wz
href http://vc.wz/l.html?q=5
在Javascript里,有两种使用正则的方法,一是创建一个正则表达式的实例,而是使用String对象里的正则表达相关的方法.
var my_regex=/[a-z]+/g;
var my_regex=new ("[a-z]+","g");
exec(string),对string进行正则处理,并返回匹配结果.
test(string),测试string是否含有匹配结果
[Edit 字符串对象中的正则]字符串对象中的正则
match(pattern) 根据pattern进行正则匹配,如果匹配到,返回匹配结果,如匹配不到返回null
search(pattern) 根据pattern进行正则匹配,如果匹配到一个结果,则返回它的索引数;否则返回-1
replace(pattern,replacement) 根据pattern进行正则匹配,把匹配结果替换为replacement
split(pattern) 根据pattern进行正则分割,返回一个分割的数组