Section 1

Preview this deck

Boolean Logical Operators

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (24)

Section 1

(24 cards)

Boolean Logical Operators

Front

Syntax expression1 && expression2 // Returns true if both the expressions evaluate to true expression3 || expression4 // Returns true if either one of the expression evaluates to true !expression5 // Returns the opposite boolean value of the expression

Back

Ternary Operator

Front

Syntax condition ? expr1 : expr2 Example const grade = 85; console.log('You ' + (grade > 50 ? 'passed!' : 'failed!'));

Back

ACCESSING NESTED ARRAY ELEMENTS

Front

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). array[index][index]

Back

WHILE LOOPS

Front

Used when you dont know how many times that you will loop let x = 0; while (x < 5) { console.log(x); // Prints numbers from 0 to 4 x++; }

Back

ARRAY CONSTRUCTOR

Front

example: const stuff = new Array(); stuff[0] = 34; stuff[4] = 20; stuff; // [34, undefined, undefined, undefined, 20]

Back

If statement

Front

It simply states that if this condition is true, do this, else do something else (or nothing). It occurs in varied forms. if (animal == 'dog') { console.log('Bark, bark!'); } else { console.log('Meow!'); }

Back

Function syntax

Front

function greet(name) { return 'Hello' + name + '!'; }

Back

FOR LOOPS

Front

You use for loops, if you know how often you'll loop. The most often used varName in loops is i. for ([let i = startValue]; [i < endValue]; [i+=stepValue]) { // Loop code here } LOOKS LIKE for (let i = 0; i < 5; i++) { console.log(i); // Prints the numbers from 0 to 4 }

Back

MULTI-DIMENSIONAL ARRAYS

Front

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. example: const multidimensionalArray = [[1,2,3],[4,5,6],[7,8,9]];

Back

Object property access

Front

obj['name']; // 'Bob' obj.name; // 'Bob' obj.getAge(); // 24

Back

ES6 CONST AND LET

Front

let and const are both scoped to the block in which they are initialized. This can be a smaller scope than var variables, which are scoped to the function in which they are initialized.

Back

== VS. ===

Front

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 produces unwanted results.

Back

Code comments

Front

// For single line /* For multi-line */

Back

Array Literals

Front

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. example const arrayName = [element0, element1, ..., elementN];

Back

Function

Front

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 it somewhere in the scope from which you wish to call it. A function definition (also called a function declaration) consists of the function keyword, followed by the name of the function, a list of arguments to the function, enclosed in parentheses and separated by commas, the JavaScript statements that define the function, enclosed in curly braces, { }.

Back

String concatenation

Front

Syntax string1 + string2 Example 'some' + 'text'; // returns 'sometext'

Back

Retrieve array element

Front

You can get elements out of arrays if you know their index. Array elements' indices 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 index is 2, etc. (example) var primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]; primes[0]; // 2

Back

OBJECT LITERALS

Front

Arrays but with key-value pairs var obj = { name: 'Bob', married: true, 'mother\'s name': 'Alice', 'year of birth': 1987, getAge: function () { return 2012 - obj['year of birth']; }, 1: 'one' };

Back

Function Hoisting

Front

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. hoistedFunction(); // Hello! I am defined immediately! function hoistedFunction () { console.log('Hello! I am defined immediately!'); }

Back

VARIABLE ASSIGNMENT

Front

var x = 1; var myName = 'Bob'; var hisName = myName;

Back

Do While loops

Front

You use do while loops, if you have to loop at least once, but if you don't know how often. let x = 0; do { console.log(x); // Prints numbers from 0 to 4 x++; } while (x < 5);

Back

ELSE IF

Front

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. if (someNumber > 10) { console.log('Numbers larger than 10 are not allowed.'); } else if (someNumber < 0) { console.log('Negative numbers are not allowed.'); } else { console.log('Nice number!'); }

Back

Function Calling Syntax

Front

functionName(argument1, argument2, ..., argumentN);

Back

For Each (MOST IMPORTANT ONE FOR DATABASE CODING)

Front

The JavaScript Array .forEach() method executes a callback function on each of the elements in an array in order. const numbers = [28, 77, 45, 99, 27]; numbers.forEach(number => { console.log(number); });

Back