Changes

JavaScript Variable Types

1 byte removed, 20:36, 19 June 2007
no edit summary
</pre>
JavaScript is also much more flexible than many other programming languages. With languages such as Java a variable must be declared to be a particular type when it is created and once created, the type cannot be changed. This is referred to as ''strong typing''. JavaScript, on the other hand, allows the type of a variable to be changed at any time simply by assigning a value of a different type (better know nas known as ''loose typing''). The following example is perfectly valid use of a variable in JavaScript. At creation time, the variable is clearly of type ''number''. A later assignment of a ''string'' to this variable changes the type from ''number'' to ''string''.
<pre>
== The JavaScript ''typeof'' Operator ==
The flexible nature of JavaScript variable types can lead to confusion as to the particualr particular type of a variable at any given time in a script. To address this concern JavaScript provides the ''typeof'' operator. The ''typeof'' operator returns the current variable type of the specified variable. For example the following script:
<pre>