如何在Javascript中调用函数 [英] How to call a function in Javascript

查看:84
本文介绍了如何在Javascript中调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编程新手 - 如果这个问题有点显而易见,那么使用codeademy来帮助解决这个问题。我主要希望能够调用一个函数。我有复制和粘贴代码学院的东西下面,我主要想知道我要做什么来打电话问候功能。如果你能解释到底该怎么做,那会很好。

 下面是问候语的功能! 
//请参阅第7行
//我们可以使用加号(+)
将字符串连接在一起//请参阅提示以获取有关这些工作原理的更多详细信息。

var greeting = function(name){
console.log(很高兴见到你,++ name);
};

//在第11行,调用greeting函数!`


  greeting(My名称); //会调用函数并产生很高兴见到你,我的名字); 


I am new to programming-and using codeademy to help with that so pardon me if this question is a bit of an obvious one. I mainly want to be able to call a function. I have copy and pasted the code academy stuff below and I mainly want to know what I have to do to "call the greeting function". If you could explain exactly what to do any why, that would be great.

Below is the greeting function!
// See line 7
// We can join strings together using the plus sign (+)
// See the hint for more details about how this works.

var greeting = function (name) {
console.log("Great to see you," + " " + name);
};

// On line 11, call the greeting function!`

解决方案

To call the greeting function this is all you need to do:

greeting("My Name"); // will call the function and produce "Great to see you, My Name");

这篇关于如何在Javascript中调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆