JavaScript 鍑芥暟
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript 鍑芥暟相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/header' title='header'>header state cti toc function 鍑芥暟瀹氫箟 瀹氫箟 parameter
鍦?JavaScript 涓紝鍑芥暟鏄?strong>澶寸瓑锛?code>first-class锛夊璞★紝鍥犱负瀹冧滑鍙互鍍忎换浣曞叾浠?strong>瀵硅薄涓€鏍峰叿鏈夊睘鎬у拰鏂规硶銆傚畠浠笌鍏朵粬瀵硅薄鐨勫尯鍒湪浜庡嚱鏁板彲浠ヨ璋冪敤銆傜畝鑰岃█涔嬶紝瀹冧滑鏄?Function
瀵硅薄銆?/p>
鍑芥暟瀹氫箟
- 鍑芥暟鍚嶏紙
name
锛夈€?/li> - 浼犻€掔粰鍑芥暟鐨勫弬鏁帮紙
parameter
锛夛紝涓€涓嚱鏁版渶澶氬彲浠ユ湁 255 涓弬鏁般€?/li> - 缁勬垚鍑芥暟浣撶殑澹版槑璇彞锛?code>statements锛夈€?/li>
瀹氫箟鍑芥暟
瀹氫箟鍑芥暟鏈夊绉嶆柟娉?
function square(number) {
return number * number;
} // 娌℃湁鍒嗗彿
function multiply(x, y) {
return x * y;
} // 娌℃湁鍒嗗彿
const square = function (number) {
return number * number;
};
const multiply = function (x, y) {
return x * y;
};
const square = (number) => {
return number * number;
};
const multiply = (x, y) => {
return x * y;
};
const square = new Function("number", "return number * number"); // 涓嶆帹鑽?
const multiply = new Function("x", "y", "return x * y"); // 涓嶆帹鑽?
function multiply(x, y) {
return x * y;
} // 娌℃湁鍒嗗彿
const multiply = function (x, y) {
return x * y;
};
const square = (number) => {
return number * number;
};
const multiply = (x, y) => {
return x * y;
};
const square = new Function("number", "return number * number"); // 涓嶆帹鑽?
const multiply = new Function("x", "y", "return x * y"); // 涓嶆帹鑽?
const multiply = (x, y) => {
return x * y;
};
const multiply = new Function("x", "y", "return x * y"); // 涓嶆帹鑽?
浠庢妧鏈搴﹁锛岃繖鏄竴涓嚱鏁拌〃杈惧紡銆備絾鏄紝涓嶆帹鑽愪娇鐢ㄨ繖绉嶆柟娉曞畾涔夊嚱鏁帮紝鍥犱负杩欑璇硶浼氬鑷磋В鏋愪袱娆′唬鐮侊紙绗竴娆℃槸瑙f瀽甯歌 ECMAScript 浠g爜锛岀浜屾鏄В鏋愪紶鍏ユ瀯閫犲嚱鏁颁腑鐨勫瓧绗︿覆锛夛紝浠庤€屽奖鍝嶆€ц兘銆備笉杩囷紝杩欑璇硶瀵逛簬鐞嗚В 鈥滃嚱鏁版槸瀵硅薄锛屽嚱鏁板悕鏄寚閽堚€?鐨勬蹇靛€掓槸闈炲父鐩磋鐨勩€?/p>
以上是关于JavaScript 鍑芥暟的主要内容,如果未能解决你的问题,请参考以下文章