ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Declaring Functions Functions, like variables, must be declared. Let's declare a function `double` that accepts an **argument** called `x` and **returns** the double of x : ~~~ function double(x) { return 2 * x; } ~~~ > *Note:* the function above **may** be referenced before it has been defined. Functions are also values in JavaScript; they can be stored in variables (just like numbers, strings, etc ...) and given to other functions as arguments : ~~~ var double = function(x) { return 2 * x; }; ~~~ > *Note:* the function above **may not** be referenced before it is defined, just like any other variable. Exercise Declare a function named `triple` that takes an argument and returns its triple. ~~~ ~~~