In javascript how can u write meatball(x) instead of meatball(var x)

+1 Ninad Bagwe · October 4, 2015
I have studied Java but never up till now have 
I seen a function prototype like 
meatball (x) how even in any scripting languages
Will the browser understand that x is a variable

Post a Reply


Oldest  Newest  Rating
+2 alex constantin · October 5, 2015
The language, by default, interprets as anything in between those function parentheses as a parameter. Like in Python, it is dealt and worked out by the browser. Java, which I do not have much experience with, I guess is more specific to what parameter type it accepts.
+2 Bram Dekker · October 5, 2015
JavaScript does not have strict types like in Java. You can pass in anything you want as the parameter x (Strings, Objects, doubles, floats et cetera).  In JavaScript you add var before a variable identifier to declare the variable in the scope that you are in. If you omit the var, you declare your variable to the global scope which makes it accessible from other scopes. 

window.onload = function() {

y = 'yes'; 
function newStuff() { 
var n = 'no'; //this will throw an error when referenced outside the function scope
g = 'global'; //this will be accessible outside the function scope.


Here is a nice overflow answer: 
Here is an explanation of scoping in JavaScript:
  • 1



A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.