Reference

Below is a cheat sheet for methods, functions, or properties from different programming languages. This will come in handy when you want to plug and play into your code without having to dig deeper into what these do. You are still encouraged to familiarize yourself with the items below in further detail by visiting their respective pages on sites such as www.w3schools.com or api.jquery.com.

Getting the data type of a variable

PHP: gettype($variable);
JS: typeof(variable);

Determining type of object

PHP: ($variable instanceof obj)
JS: (variable instanceof obj)
Java: (variable instanceof obj)

Finding length of a string

PHP: strlen($string);
JS: string.length;
Java: string.length();

Creating an empty array

PHP: $myArray = [];
JS: var array = new Array();
Java: int[] array = new int [5];

Slicing an array

PHP: array_slice($array_name, start position, number of elements to extract(O), true/false(O));
JS: slice(start, end);
Java: Click here

Finding length of an array

PHP: count($array);
JS: array.length;
Java: array.length();

Find location of an item in a string

PHP: strpos($str, item);
JS: string.indexOf(item);
Java: string.indexOf(item);

Find character at location in string

PHP: no eqiuvalent
JS: string.charAt(pos);
Java: string.charAt(pos);

Returning part of or slicing a string

PHP: substr($str, start, length);
JS: string.slice(start, end);
            string.substring(start, end);
            string.substr(start, length);
Java: string.substring(start, end);

Trim characters in a string

PHP: trim($str, characterList);
JS: string.trim(); – removes whitespace only
Java: string.trim(); – removes whitespace only