UrbanPro

Learn Java Script Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

JavaScript: Why do I have to create a var and a function for a .onclick event when I only want it to create a function?

Asked by Last Modified  

Follow 2
Answer

Please enter your answer

Use of var means variable valid for only current execution context or local context or the variable is local.
Comments

IT Professional Trainer with 15 years of experience in IT Industry

Your question is not clear. But I will give you an answer to your question. var is initializer ob variables / HTML elements object. When you are want to create an event function that time you needs some elements, objects will be works in your function. So you need to create var for init for your elem...
read more

Your question is not clear. But I will give you an answer to your question.
var is initializer ob variables / HTML elements object. When you are want to create an event function that time you needs some elements, objects will be works in your function. So you need to create var for init for your elements.

read less
Comments

IT Professional Trainer with 15 years of experience in IT Industry

You don’t. You can pass an anonymous function to the onClick. object.onclick = e => { // handle event here...};or object.addEventListener(“click”, e => { // handle event here...});
Comments

View 1 more Answers

Related Questions

What is an Array?

An array is a collection of (same or different type of) items.In Java and C#, etc., the elements inside the array should be of the same type (e.g. ) while in languages like JavaScript and Python. The elements can be different types also(e.g. )
M
x eskor plus two x plus one
what is the question? can't understand the meaning.
Ankur
0 0
8
I know HTML, CSS, and a bit of JavaScript. What should I learn next?
HTML,CSS and Javascript are Tools which are used for Front-End Web Development. The next step is to learn the following: 1)Learn Javascript Frameworks like node.js,react.js,angular.js etc. 2)Learn Back-End...
Inch By
Should I learn Python or JavaScript as a newbie?
Python is different from javascript. I prefer you go with python as it is in boom now.
Manisha
0 0
6
How do I become better at JavaScript?
Go through JavaScript tutorials from w3schools.com site. They have good examples with description. Then learn some es6 and es7 syntax. You will be pro in JavaScript.
Pooja
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

What is hoisting in Javascript?
As a matter of fact it is, javascript is an interpreted language and the javascript interpreter performs a lot of mystical stuff behind the scenes. Hoisting in JavaScript is certainly one of them. A quick...

Web Technology Tutorial
Web Technology has 2 category Front End (HTML,CSS,JS Etc) Back End/Server Side (PHP,JSP,ASP,ROR Etc) Front End technologies are - HTML, CSS, Bootstrap, Javascript, jQuery etc. Using front end...

Angular 1 vs Angular 2
Angular team has released the angular 2, which has drastically change the way programmers interact and work with Angular framework in the past. In this post I will tell you the common changes made by...

String Comparison In Javascript
String Comparison in javascript: Let us learn how two strings are compared in javascript Assume you have two strings: "ant" and "ele" Case 1: alert("ant" < "ele" ); will give the result as true...
G

Some good resources
Clean Code by Robert C Martin, is available in my profile please download and read it, irrespective of what language you code in, it will change the way you code. Also if you code in Javascript read https://12factor.net/ https://blog.risingstack.com/javascript-clean-coding-best-practices-node-js-at-scale/ For...

Recommended Articles

Here are the top 6 must have skills for every Web Designer : Technical Skills Web designers undoubtedly require very strong technical skills. They must have hands on using Web designing software and tools, such as Adobe Dreamweaver, Fireworks, Photoshop, Flash etc. In addition to the knowledge of design...

Read full article >

Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...

Read full article >

Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

Read full article >

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Looking for Java Script Training classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Script Training Classes?

The best tutors for Java Script Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Script Training with the Best Tutors

The best Tutors for Java Script Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more