click below
click below
Normal Size Small Size show me how
jdrugan-JavaScript
Beginning JavaScript Vocabulary
Term | Definition |
---|---|
Array literals | You can create arrays in two different ways. The most common of which is to 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 | You can get elements out of arrays if you know their index. 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. |
Array constructor | You can also create an array using the Array constructor. |
Accessing nested array elements | Accessing multi dimensional array elements is quite similar to one-dimension arrays . They are accessed by using [index][index]..... (number of them depends upon the number of arrays deep you want to go inside). |
Boolean literals | True and false. |
Boolean logical operators | Logical expressions, like comparison expressions, return a true (1) or false (0) value when processed. Logical operators combine two comparisons and return the true (1) or false (0) value depending on the results of the comparisons. |
Note: | An important thing to note here is that not only Boolean literals (true and false) assert truth or false , but there are some other ways too to derive true or false.Have a look at the examples. |
==vs.=== | A simple explanation would be that == does just value checking ( no type checking ) , whereas , === does both value checking and type checking . Seeing the examples may make it all clear. It is always advisable that you never use == , because == often pro |
Definition | Code comments are used for increasing the readability of the code.If you write 100 lines of code and then forget what each function did , it's not useful at all. Comments are like notes , suggestions , warnings ,etc. that you can put for yourself. Code co |
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.You give each timer a unique name, and may have up to 10,000 timers running on a given page.When you call console.timeEnd() with the same name, the browser wil |
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.It is like a reusable piece of code. Imagine , having 20 for loops ,and then having a single function to handle it all . To use a function, you must define |
Function calling | Calling the function involves specifying the function name |
Function hoisting | The two ways of declaring functions produce different results. Declaring a function one way "hoists" it to the top of the call, and makes it available before it's actually defined. |
if | It simply states that if this condition is true , do this , else do something else ( or nothing ) . It occurs in varied forms. |
else | A fallback to an if statement. This will only get executed 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 Loops | 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 to 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 | Returns 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 | Doing basic arithmetic is simple. |
Prefix and Postfix increment/decrement operators | Prefix increment / decrement operators are operators that first increase the value of the variable by 1 (increment) or decrease the value of an expression / variable by 1 (decrement) and then return this incremented / decremented value. They are used like |
Object Literals | An object literal is a comma separated list of name value pairs wrapped in curly braces. |
Property Access | Property accessors 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 (OOP). |
alert | Display an alert dialog with the specified message and an OK button. Note: 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 | establish the truth or correctness of (something previously believed, suspected, or feared to be the case). |
prompt | The prompt() displays a dialog with an optional message prompting the user to input some text. If the user clicks the "Cancel" button , null is returned. |
Concatenation | a series of interconnected things or events. |
length | Returns the length of the string. |
trim() | Removes whitespace 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. Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character in a string called stringName is stringName.length - 1. If the index you suppl |
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 | Use the switch statement to select one of many blocks of code to be executed. |
Variable Assignment | the assignment operator (no space before and after) |
Variable changing | A change in a variable. |
Strings | Strings are text. They are denoted by surrounding text with either single or double quotes. |
toUpperCase, toLowerCase | Changes the cases of all the alphabetical letters in the string. |
Ternary Operator | The ternary operator is usually used as a shortcut for the if statement. |
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. |