Cod*_*ahk 11 javascript google-chrome v8
几天前,当我们为变量$ x分配一个字符串时,我和朋友正在玩Chrome中的Javascript控制台(使用稍微旧的版本,但这可以在OSX和Windows上的最新稳定版本中重复) .
$x = "hello"
Run Code Online (Sandbox Code Playgroud)
但是当我们回显$ x的值时,我们在控制台中得到以下代码:
bound: function (xpath, context)
{
var doc = (context && context.ownerDocument) || inspectedWindow.document;
var result = doc.evaluate(xpath, context || doc, null, XPathResult.ANY_TYPE, null);
switch (result.resultType) {
case XPathResult.NUMBER_TYPE:
return result.numberValue;
case XPathResult.STRING_TYPE:
return result.stringValue;
case XPathResult.BOOLEAN_TYPE:
return result.booleanValue;
default:
var nodes = [];
var node;
while (node = result.iterateNext())
nodes.push(node);
return nodes;
}
}
Run Code Online (Sandbox Code Playgroud)
我们在Safari和Firefox的稳定版本中获得了类似的输出.据我们所知,$ x变量未附加到全局窗口对象.
什么是$ x,它用于什么?
mu *_*ort 11
这是一个XPath实用程序函数.从精美的Firebug手册:
$x(xpath)
返回与给定XPath表达式匹配的元素数组.
$x(xpath)
返回与给定XPath表达式匹配的DOM元素数组.
该$x函数不是JavaScript本身的一部分,它只是控制台中可用的实用程序.如果你试图$x在控制台外访问(http://jsfiddle.net/ambiguous/fsewU/),你会得到一个ReferenceError,当然,除非你已经定义了自己的$x某个地方.
| 归档时间: |
|
| 查看次数: |
6220 次 |
| 最近记录: |