我在Firefox Developer Edition 38和Internet Explorer 8和9中运行以下JavaScript.
console.log('+++++++++++++++++++++++++++++++');
console.log('jquery version = ' + $.fn.jquery);
var myHtmlString = "<!-- my comment -->" +
"<optgroup label='my label'>" +
"<option value='1'>option one</option>" +
"</optgroup>";
console.log($(myHtmlString));
console.log($(myHtmlString)[0]);
console.log($(myHtmlString)[1]);
console.log($(myHtmlString).length);
Run Code Online (Sandbox Code Playgroud)
在Firefox中,我得到:

在IE中,我得到:

因此,显然在Firefox中,HTML注释作为此对象的元素被添加,但在IE中,它不是.为什么这样做,是否有错误,还是我应该创建这个对象的另一种方式?
注意:我试过,$.parseHTML(myHtmlString)但它做了同样的事情.
更新:这个答案jQuery如何处理注释元素?提供了潜在的解决方法.
这些似乎是相同的.有偏好,性能差异等吗?
Hash[[[:a, 'foo'], [:b, 'bar']]]
#=> {:a=>"foo", :b=>"bar"}
[[:a, 'foo'], [:b, 'bar']].to_h
#=> {:a=>"foo", :b=>"bar"}
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个lambda脚本,可以从站点中提取图像并将其存储在S3中.我遇到的问题是什么样的对象作为Body属性传递给S3.putObject方法.在这里的文档中它说它应该是new Buffer('...') || 'STRING_VALUE' || streamObject,但我不知道如何将https响应转换为其中之一.这是我尝试过的:
var AWS = require('aws-sdk');
var https = require('https');
var Readable = require('stream').Readable;
var s3 = new AWS.S3();
var fs = require('fs');
var url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/AmazonWebservices_Logo.svg/500px-AmazonWebservices_Logo.svg.png';
exports.handler = function(event, context) {
https.get(url, function(response) {
var params = {
Bucket: 'example',
Key: 'aws-logo.png',
Body: response // fs.createReadStream(response); doesn't work, arg should be a path to a file...
// just putting response errors out with "Cannot determine length of [object Object]" …Run Code Online (Sandbox Code Playgroud)