[jquery] jQuery点滴[持续更新]

时间:2023-03-09 02:04:34
[jquery] jQuery点滴[持续更新]

001.查看jquery的版本.

$(function(){
console.log($());
//jquery
console.log($().jquery);
});

002.(new Function('return ' + s))() 相当于是用eval来解析一个字符串.

* eval -> 参见 jquery.parser.js
|- (new Function('return ' + s))() 相当于是用eval来解析一个字符串.
// new Function 参考 -> http://www.w3school.com.cn/js/pro_js_functions_function_object.asp
// 下面的代码实际是返回一个JSON.类似eval ->
// 参考 http://*.com/questions/2449220/jquery-uses-new-functionreturn-data-instead-of-evaldata-to-parse
options = (new Function('return ' + s))();

譬如:

var s = 'width:100,height:200,require:true';
var options = (new Function('return ' + s))();
console.log('options:', options);
console.log(options['width']);
//output:
//options: Object {width: 100, height: 200, require: true}
//100

003.