answersLogoWhite

0

How do you write functions in JavaScript?

Updated: 8/20/2019
User Avatar

Wiki User

11y ago

Best Answer

There are several methods, all leading to a similar place.

The first is to simply declare a function using the function keyword:

function ourFunction(args){}

The second is to assign a variable as a function:

var ourFunction = function(args) {};

And the third (commonly used in JavaScript frameworks, or when function is being passed as a parameter) is to just use an anonymous function.

window.onload = function(args) {};

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write functions in JavaScript?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between Javascript and Jquery?

JavaScript is a scripting language that is mainly used within a web browser. Jquery is a library of javascript code that can be used together with your javascript program. A set of functions that can preform common tasks is provided, which will reduce the amount of code that you have to write yourself.


How do you write a javascript?

go to notepad and write Javascript code and save it as .js and then import it into a page with a src tag


How do you write HTML codes and javascript events together in your HTML kit?

You need to write the HTML code in the tag format. If you want to write JavaScript put it in <script> tag.


What are the main functions of Javascript?

Javascript can be used on a variety of platforms which require simple computer commands but not a full programming language. Javascript can be used as or in addition to a full fledged programming language.


When are the javascript functions compiled?

JavaScript functions are compiled by the client machine at run-time. This is different than a lot of older code, but similar (at least in effect) to modern languages like C# and Java.


How to use Javascript to write to the local filesystem?

For security reasons, regular JavaScript scripts in web pages are not allowed to write to the local file system.


What languages can you write a Google Apps script on?

JavaScript


How do you call the any functions in java?

Just like JavaScript, it is in this format: functionName(moreInfo);


What JavaScript terms are used to describe the actions performed of an object?

JavaScript is an object-oriented language, and like most OO languages, the actions that are performed on an object are referred to as methods. In JavaScript, methods are also sometimes called functions.


Where do you write javascript?

JavaScript is written in an HTML document. You start it with this tag:and end it with:


What are good Java script codes?

depending on the intention of the javascript codes you wish to write. there is much you can do with javascript but the only way to find out what "good Java script codes" are is to explore what you want the Javascript to do on the page.


How can we say that JavaScript is Not Object-Oriented language?

Probably due to the reasoning that javascript is simply a branch of html that allows you to run external functions to make the webpage do things, so that may be why.