当前位置: 首页 > 图文教程 > 网络编程 > Javascript > JavaScript 高级语法介绍

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 中的 JavaScript 高级语法介绍


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

前几天一个同事问我如下的JavaScript代码如何理解

(function($){})(jQuery);

其实比较简单,要理解几个概念:

1、(),在JavaScript里()表示执行一个方法,如:

function x(){

alert("xxx");

}

var a = x; // 没有调用,a 是一个function

var a = x(); //调用了函数,a 的值是调用的结果:undefined

2、jQuery是一个jQuery对象,表示调用函数时,传入一个参数是jQuery对象。

这个没什么好说的

3、(function($){})这是一个匿名函数,形参是$,括号是一定需要的。

这样一看就懂了,上式相当于

var f = function($){};

f(jQuery);

现现看看,即不简单也不诡异...