answersLogoWhite

0

What is a method in JavaScript?

Updated: 8/20/2019
User Avatar

Wiki User

10y ago

Best Answer

Hi there, a method is a "function" in a object. Example:

function answers(){

this.world = function(){alert("hello world")};

}

var hello = new answers();

hello.world(); <--- world is a method of the object hello.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a method in JavaScript?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What JavaScript method is most commonly used to generate output?

alert and prompt


What does javascript this mean?

In javascript, the word "this" refers to the &#144;&cent;&laquo;&Ecirc;&laquo;_owner&#144;&cent;&laquo;&Ecirc;&laquo;&#157; of the function being executed. Put another way, "this" means the object that a function is a method of.


What happens during an onclick event in javascript?

Whatever method is attached to the event, is executed.


What is a example of a class is Javascript. Describe the properties and one method. Give two examples of objects of that class?

JavaScript is a prototype based object oriented language. This means that it doesn't have classes.


What is the meaning behind a javascript split?

The javascript split method, split(), will alter a string to make it into an array of substrings. This is useful if you would like to store each substring from the original string seperately.


How do you show the location of an occurrence of the letter e in a string using javascript?

The location of a substring within a string in JavaScript can be found using the indexOf() method of the string type. That method will return the placement of a string as a numerical index, starting from 0. The method takes two arguments. The first is the substring you're looking for. In this case "e." The second argument is optional, and it's the "start" argument. If you define it, you define the index from which JavaScript will start looking for the substring. By default, this index is 0 (zero.) If you want to find all of the occurrences of a string using this method, you have to write a loop. To see a working example of that, check out the JSFiddle in the related links. I've also attached a good lesson on JavaScript strings in PDF.


What is the mousePressed function for?

It seems as though this is part of Java.Swing or JavaScript. In this case this method will be called when the mouse is initially clicked on the object.


What is a javascript tutorial?

A JavaScript tutorial contains instructions that will teach you how to code in JavaScript.


What are built-in javascript classes?

Javascript does not have classes


How do you sort in javascript?

Javascript can help in browseing


How old is Javascript?

Javascript was created in 1995.


How do you write javascript code to close a browser window?

If you want to close the current window, use window.close() or simply close() If you want to close a window that is stored in a JavaScript variable, apply the method close() to it. For example: var myWindow=window.open("http:\/\/www.example.com/"); myWindow.close();