function testabc(a, b, c) {
a = typeof a !== 'undefined' ? a : '1';
b = typeof b !== 'undefined' ? b : '2';
c = typeof c !== 'undefined' ? c : '3';
alert(b);
}
testabc(b='b');
JS不能这么用吗?类似$.ajax这种用法是如何实现的呢?
$.ajax({
url: 'xxx'
});
第一个,JavaScript是不能这么用的。你可以这样:
对于
$.ajax()
,它是jQuery提供的一个方法,$
指jQuery,而ajax
是它提供的一个方法,这相当于往ajax()
方法传了个参数。如果你想要和
$.ajax()
这样传参数,你需要这样做: