<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.gtaconnected.com/wiki/index.php?action=history&amp;feed=atom&amp;title=ScriptingTutorials%2FJavaScriptTutorial</id>
	<title>ScriptingTutorials/JavaScriptTutorial - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.gtaconnected.com/wiki/index.php?action=history&amp;feed=atom&amp;title=ScriptingTutorials%2FJavaScriptTutorial"/>
	<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingTutorials/JavaScriptTutorial&amp;action=history"/>
	<updated>2026-05-10T12:49:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.15</generator>
	<entry>
		<id>https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingTutorials/JavaScriptTutorial&amp;diff=3839&amp;oldid=prev</id>
		<title>Mex at 13:23, 14 August 2018</title>
		<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingTutorials/JavaScriptTutorial&amp;diff=3839&amp;oldid=prev"/>
		<updated>2018-08-14T13:23:58Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:JavaScript Tutorial}}&lt;br /&gt;
This page shows some of the functionality in JavaScript. Be sure to reference the [https://www.ecma-international.org/publications/standards/Ecma-262.htm official ECMAScript (JavaScript) manual] when you can.&lt;br /&gt;
==Comments==&lt;br /&gt;
{{JSCode|1=// this is a single line comment, which can appear at the end of any line}}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=/*&lt;br /&gt;
this is a multi line comment,&lt;br /&gt;
which can appear anywhere&lt;br /&gt;
*/&lt;br /&gt;
}}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions==&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=someFunction(); // this is a call to a function named someFunction, the code for that function will run when the function is called}}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=someFunction(5, 400, 5000); // this is a call to a function, sending 3 parameters to it. a parameter is an input value for a function}}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=// this is a function definition, which is a portion of code, don&amp;#039;t forget the closing curly bracket to end the function definition&lt;br /&gt;
function someFunction() {&lt;br /&gt;
} }}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=// this is a function definition, which takes 3 parameters. parameters are also called arguments&lt;br /&gt;
function someFunction(arg1, arg2, arg3) {&lt;br /&gt;
} }}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=// this is a function without a name, also known as a lambda function&lt;br /&gt;
function() {}; }}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=// this is a function which adds 2 numbers&lt;br /&gt;
// the word return is used to set the output of the function, as well as to stop the function running at the expression after the word return&lt;br /&gt;
// the result of add(..) is stored inside a variable named result&lt;br /&gt;
function add(a, b) {&lt;br /&gt;
    return a + b;&lt;br /&gt;
}&lt;br /&gt;
var result = add(40, 20);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Data Types==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;string&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{JSCode|1=&amp;#039;this is a string&amp;#039;&lt;br /&gt;
&amp;quot;this is a string&amp;quot;}}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;number&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{JSCode|1=20&lt;br /&gt;
40.0&lt;br /&gt;
99e5&lt;br /&gt;
-20&lt;br /&gt;
-40.0}}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;boolean&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{JSCode|1=true&lt;br /&gt;
false}}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;null&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{JSCode|1=null&lt;br /&gt;
&lt;br /&gt;
someVariable = null; // set a variable to null, the variable still exists}}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;undefined&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{JSCode|1=delete someVariable; // delete a variable, the variable no longer exists, and evaluates to undefined}}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;object&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{JSCode|1={} // an empty literal object&lt;br /&gt;
&lt;br /&gt;
{&amp;#039;aa&amp;#039;:5, &amp;#039;bb&amp;#039;:10} // a object literal with 2 elements, element with key aa has value 5, and element with key bb has value 10&lt;br /&gt;
&lt;br /&gt;
function SomeClass() {&lt;br /&gt;
}&lt;br /&gt;
var someObject = new SomeClass; // an object of class SomeClass&lt;br /&gt;
}}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Data type &amp;#039;&amp;#039;&amp;#039;symbol&amp;#039;&amp;#039;&amp;#039; also exists.&lt;br /&gt;
&lt;br /&gt;
==Intrinsic Data Types==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Array&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{JSCode|1=[20, 50, 80] // an array with 3 elements, keys are 0 1 and 2, values are 20 50 and 80, respectively.}}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Function&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{JSCode|1=function() {} // an empty function with no name&lt;br /&gt;
&lt;br /&gt;
function someFuncName() // an empty function with a name&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
someFuncName = function() // an empty function with a name&lt;br /&gt;
{&lt;br /&gt;
} }}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many other intrinsic data types exist, check section 6.1.7.4 of the [http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf JavaScript Manual].&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Math Operators&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{JSCode|1=+ - * / % // these are some mathematical operators&lt;br /&gt;
&lt;br /&gt;
5 * 4 // results in 20&lt;br /&gt;
&lt;br /&gt;
5 * 4 + 2 // results in 22&lt;br /&gt;
&lt;br /&gt;
5 * (4 + 2) // results in 30}}&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=var someVariableName = &amp;#039;some string value&amp;#039;; // this creates a local variable and assigns it a string value&lt;br /&gt;
&lt;br /&gt;
someGlobalVariable = 50; // this either creates a global variable, or updates a variable, and assigns it a number value}}&lt;br /&gt;
&lt;br /&gt;
==Conditions==&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=var someVariable = 500;&lt;br /&gt;
&lt;br /&gt;
functipn print(text)&lt;br /&gt;
{&lt;br /&gt;
    // code here&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if&lt;br /&gt;
if (someVariable &amp;lt; 1000) {&lt;br /&gt;
    print(&amp;#039;value is less than 1000&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if and else&lt;br /&gt;
if (someVariable &amp;lt; 200)&lt;br /&gt;
    print(&amp;#039;value is less than 200&amp;#039;);&lt;br /&gt;
else&lt;br /&gt;
    print(&amp;#039;value is 200 or more&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// if, else if and else&lt;br /&gt;
if (someVariable &amp;lt; 100)&lt;br /&gt;
    print(&amp;#039;value is less than 100&amp;#039;);&lt;br /&gt;
else if (someVariable &amp;lt; 300)&lt;br /&gt;
    print(&amp;#039;value is less than 300&amp;#039;);&lt;br /&gt;
else if (someVariable &amp;lt; 500)&lt;br /&gt;
    print(&amp;#039;value is less than 500&amp;#039;);&lt;br /&gt;
else&lt;br /&gt;
    print(&amp;#039;value is 500 or more&amp;#039;);&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Loops==&lt;br /&gt;
&lt;br /&gt;
{{JSCode|1=functipn print(text)&lt;br /&gt;
{&lt;br /&gt;
    // code here&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// integer loop&lt;br /&gt;
for (var i=0; i&amp;lt;20; i++) {&lt;br /&gt;
    print(i);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// array loop&lt;br /&gt;
var someArray = [20,50,80];&lt;br /&gt;
for (var i in someArray) {&lt;br /&gt;
    print(someArray[i]);&lt;br /&gt;
} }}&lt;/div&gt;</summary>
		<author><name>Mex</name></author>
	</entry>
</feed>