click below
click below
Normal Size Small Size show me how
senos-javascript
Beginning Javascript Vocabulary
Term | Definition |
---|---|
Array Literals | List values in a pair of square brackets. JavaScript arrays can contain any types of values and they can be of mixed types. |
Accessing array elements | Array elements' indexes start at 0 and increment by 1, so the first element's index is 0, the second element's index is 1, the third element's is 2, etc. |
Multi-dimensional Arrays | A two-dimensional array is an array within an array. If you fill this array with another array you get a three-dimensional array and so on. |
Array constructor | A way to construct an array. |
Accessing nested array elements | Accessing multi dimensional array elements is quite similar to one dimensional arrays. They are accessed by using [index][index]. |
Boolean Literals | Syntax(true,false). |
Boolean Logical Operators | When used with Boolean values they return Boolean values.When used with non-Boolean values, they may return a non-Boolean value. |
Comparison Operators | A comparison operator compares its operands and returns a logical value based on whether the comparison is true. |
Note: | Not only Boolean literals (true and false)assert truth or false, but there are some other ways too to derive true or false. |
==VS.=== | == just does value checking (no type checking), but === does both value checking and type checking. |
Definition of Code Comments | Are used for increasing the readability of the code. They are like notes that you can put for yourself. |
Single line Comment | Anything on the line following // will be a comment while anything before will still be code. |
Multi-Line Comment | Anything between /* and */ will be a comment. |
Console.Log | Prints text to the console. Useful for debugging. |
Console.Time | This function starts a timer which is useful for tracking how long an operation takes to happen. |
Console.TimeEnd | Stops a timer that was previously started by calling console.time(). |
Function Definition | A function is a JavaScript procedure- a set of statements that performs a task or calculates a value. |
Function calling | To use a function, you must define it somewhere in the scope from which you wish to call it. |
Function hoisting | The two ways of declaring functions produce different results. Declaring a function one way "hoists" it into the top of the call, and makes it available before it is actually defined. |
If | If the condition is true, do this, else do something else (or nothing). |
Else | A fallback to an if statement. This will only execute if the previous statement did not. |
Else If | This is like an else statement, but with its own condition. It will only run if its condition is true, and the previous statement's condition was false. |
For Loops | You use for loops, if you know how often you'll loop. The most often used varName in loops is "i". |
While Loop | You use while loops, if you don't know how often you'll loop. |
Do While Loops | You use do while loops, if you have to loop at least once, but if you don't know how often. |
Random | Returns a random number between 0 and 1. |
Floor | Returns the largest integer less than or equal to a number. |
Pow | Returns base raised exponent. |
Ceil | Returns the smallest integer greater than or equal to a number. |
PI | Returns the ratio of the circumference of a circle to its diameter, approximately 3.14159 or in better terms, the value of PI (π). Note in syntax , we do not put `()` at the end of `Math.PI` because `Math.PI` is not a function. |
sqrt | Return the square root of a number. |
% (Modulus) | It returns the remainder left after dividing the left hand side with the right hand side. |
isNaN | Returns true if the given number is not a number , else returns false. |
Basic Arithmetic | 4 + 5; // 9 4 * 5; // 20 5 - 4; // 1 20 / 5; // 4 |
Prefix and Postfix increment/decrement operators | operators that first increase the value of the variable by 1 or decrease the value of an expression / variable by 1 and then return this incremented / decremented value. They are used like ++(variable) [increment] or --(varaible) [decrement] On the other |
Object Literals | An object literal is a comma separated list of name value pairs wrapped in curly braces. |
Property Access | Provide access to an object's properties. |
Classes | A class can be thought of as a template to create many objects with similar qualities. Classes are a fundamental component of object-oriented programming. |
Alert | The alert dialog should be used for messages which do not require any response on the part of the user, other than the acknowledgement of the message. |
Confirm | Make sure you want to do something. |
Prompt | The prompt() displays a dialog with an optional message prompting the user to input some text. |
Concatenation | Concatenates two string values together, returning another string that is the union of the two operand strings. |
Length | Returns the length of a string. |
toUpperCase, toLowerCase | Changes the cases of all the alphabetical letters in the string. |
trim() | Removes white space from both ends of the string. |
replace() | Returns a string with the first match substring replaced with a new substring. |
charAt() | Returns the specified character from a string. |
substring() | Returns the sequence of characters between two indices within a string. |
indexOf() | Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex, Returns -1 if the value is not found. The indexOf method is case sensitive. |
switch | Acts like a big if / else if / else chain. Checks a value against a list of cases, and executes the first case that is true. |
Variable Assignment | Assigning a variable a name. |
Variable changing | Changes the variable's name. |
Ternary Operator | The ternary operator is usually used as a shortcut for the if statement. |