关于长亭空间
超值服务提供卓越产品
// 1.length 表示形参的个数
// 2.arguments:表示所有实参的一个数组(arguments只能使用在函数的内部)
// 1.function 函数名( 形参列表 ){ 函数体 } function func1() { alert("hello"); }
// 2.var 函数名 = function( 形参列表 ){ 函数体 } var func2 = function () { alert("hi"); }
// 3.var 函数名 = new Function(形参1,形参2,...,形参N,函数体); var func3 = new Function("a", "b", "return a+b"); var result = func3(3, 4); console.log(result); function test1(a, p1, p2) { a(p1, p2); } test1(func3, 3, 4)
// 二、函数的属性 // 1.length 表示形参的个数 function test2(a, b, c, d) { return a + b; } console.log(test2.length); // 2.arguments:表示所有实参的一个数组(arguments只能使用在函数的内部) function test3(a, b, c) { console.log(arguments) return a + b + c } console.log(test3(1, 2, 3));
var add1 = function (a, b, c, d) { return a + b + c + d; } var add1 = function (a, b) { return a + b; } var add1 = function (a, b, c) { return a + b + c; } result = add1(3, 4, 5, 6); console.log(result);
//parseInt():将一个字符串转化为一个int数据 var result = parseInt("1aa23.45aa6"); console.log(result) //parseFloat():将一个字符串转化为一个float数据 result = parseFloat("12a3.4a56") console.log(result); //isNaN():判断一个number数据是否为NaN result = isNaN(parseInt("1aa23.45aa6")); console.log(result); //isFinite():判断一个数字是否是有限的 result = isFinite(1 / 0); console.log(result); //eval():解析js代码,并运行js代码 var str = "alert('haha')"; eval(str);
原文链接:https://www.cnblogs.com/aknife/p/10805085.html
如有疑问请与原作者联系