今天看到js原来有很多种定义的方式
var region = new Object();
region.isAdmin = false;
region.loadRegions = function(b, a, c) {
Ajax.call(region.getFileName(), "type=" + a + "&target=" + c + "&parent=" + b, region.response, "GET", "JSON")
};
region.getFileName = function (){
if (region.isAdmin) {
return "../region.php"
} else {
return "region.php"
}
}
这段代码是选择城市的一段代码<script type="text/javascript"> function add(num1,num2) { return num1+num2+200;} var sum=add(122,10000); window.document.write(sum); </script> <script type="text/javascript"> var add=new Function("num"," return num+200"); //此时Function 这种方法用的比较少 var sum=add(122); window.document.write(sum); </script> <script type="text/javascript"> var add=function(num1,num2){ return num1+num2+200;} var sum=add(122,300); window.document.write(sum); </script>
时间: 2024-10-17 11:40:11