[Edit 前言]

前言


Javascript是一门很自由的语言,在JS里,里面一切的东西都是变量.包括函数在内.
[Edit 基础]

基础

[Edit 函数]

函数

  • (定义)(参数1[,参数2..]) 以下代码将创建一个函数并执行它.(function (str){alert(str.length);})('test_str');

(function (str1,str2){alert(str1 str2);})('str1111','str2222');
[Edit html dom]

html dom

[Edit window]

window

[Edit window.location]

window.location


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
[Edit 正则表达式]

正则表达式


在Javascript里,有两种使用正则的方法,一是创建一个正则表达式的实例,而是使用String对象里的正则表达相关的方法.
[Edit 正则表达式对象]

正则表达式对象

[Edit 两种创建方法]

两种创建方法

  • var my_regex=/[a-z]+/g;
  • var my_regex=new ("[a-z]+","g");
[Edit 方法]

方法

  • exec(string),对string进行正则处理,并返回匹配结果.
  • test(string),测试string是否含有匹配结果
[Edit 字符串对象中的正则]

字符串对象中的正则

[Edit 方法]

方法

  • match(pattern) 根据pattern进行正则匹配,如果匹配到,返回匹配结果,如匹配不到返回null
  • search(pattern) 根据pattern进行正则匹配,如果匹配到一个结果,则返回它的索引数;否则返回-1
  • replace(pattern,replacement) 根据pattern进行正则匹配,把匹配结果替换为replacement
  • split(pattern) 根据pattern进行正则分割,返回一个分割的数组
Config........0.000311136245728 SECs
Instantiate..0.0809099674225 SECs
Render......0.00122904777527 SECs
This wiki is under GPL and the latest version can be found here.

Javascript

Navigator

KeyShortCuts