answersLogoWhite

0

The most common and shortest way to write a JavaScript array is:

var myArray=[1,2,3];

You can also use:

var myArray=new Array(1,2,3);

Or:

var myArray=new Array();

myArray[0]=1;

myArray[1]=2;

myArray[2]=3;

All of these produce the same array containing the elements 1, 2, and 3.

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering

How can you use a JavaScript variable in the PHP isset function?

You can't actually do that. There is no direct way to make JavaScript code talk to PHP code, as the two languages are interpreted in different locations. The PHP is interpreted by the server, and the JavaScript is interpreted by the client. This means it's easy enough to transfer data from PHP to JavaScript (by generating the JavaScript with the PHP), but not the other way around. If you're simply looking for a way to see if a JavaScript variable is set (from within the JavaScript itself), that can be done with a line like this one: if(myVariable !== undefined){ /* do stuff */} If you actually want to handle it on the PHP side, one way to do so would be to use additional PHP code when that happens. For example: <?php $jsVars = array(); ?> <script type="text/javascript"> var foo = 'bar'; <?php $jsVars['foo'] = 'bar';?> var yub = 'nub'; <?php $jsVars['yub'] = 'nub';?> </script> ... You can then check to see whether a certain variable has been set by seeing if it's in that array: <?php function jsIsset($varname){ global $jsVars; return array_key_exists($varname, $jsVars); } ?> This however, only works when the JavaScript is generated, not when it's interpreted by the client system. For example, imagine you have a variable that is defined by a JavaScript function that is called from an onclick event. By the time that event happens, the page has already been served and the PHP is done executing. If you want the JavaScript to tell the PHP that a variable is defined, you would need to do it through an AJAX request, which I believe is beyond the scope of this question.


How do you write a program which reads a list of ten numbers and print the list in reserve order in c program?

The simplest way is probably to read the numbers into an array and then prints each element of the array starting at the last one and moving backwards.


What is character array?

In other way Character array is called strings.A group of characters can stored in a character array. e.g. char name[] ={'S','A','T','Y','A','\0'};


How do you put java script into HTML?

Javascript inside html <html> <head> <script type="text/javascript" language="javascript"> // Java script code here </script> <body> // html code here </body> </html> Via External Link: <html> <head> <script type="text/javascript" language="javascript" src="location of js file"> </script> <body> // html code here </body> </html>


How do you restart your computer with JavaScript?

There is no known way to restart a computer system in Javascript. Javascript is a web programming language that allows web page functionality such as user input, animation, creatings graphs or charts, and making changes to a page based dynamic data.

Related Questions

Can you compute one array in c say and then assign b to a?

Yes, you can. You have to do that in the following way. Each element of A should be assighed each element of B. You have to do it manually means you have to write a loop which will do it for you. In C array A = array B is not correct.


What is the correct way to write hundred and twenty?

The correct way to write it is ' 120 '.The correct way to say it is "One hundred twenty".


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.


What is the correct way to write fireplace?

The correct way to write fireplace is as one word - "fireplace."


Correct way to write 3 am?

the correct way is to simply write 3 and a colon following it then write down 2 zeroes followed by hrs


What is the correct way to write 95 in standard form?

The correct way to write 95 in standard form is 9.5 × 101


What is the correct way to write the year 1012?

1012 is the correct way to write it but if you mean in words the 1 thousand and twelfth


What is the correct way to write 'have you had a chance' or 'did you had a chance'?

In English, either way of saying this phrase is correct.


What is the correct way to write New Years' Eve or New Year's Eve?

The correct way is to write New Year's Eve.


How you write spread?

the correct way to write it is like this; spread


What is the correct way to write 12.00 noon?

The correct way to write 12:00 noon is "12:00 PM."


What is the correct way to write 7200000?

7,200,0000