Javascript Flashcards

1
Q

Javascript

A

https://developer.mozilla.org/en-US/docs/Web/JavaScript

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

alert( )

A

Pop up message to give user an alert.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Data Type

A

Don’t have to specify anything specifically (most of the time). We can force it to recognize certain characters are numbers though.

Data types include “string”, number, boolean.

You can check data type using typeOf( ‘variable here’ )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Variable and Constants.

A

Variables are declared with ‘var’ and ‘let’
Constants are declared with ‘const’.

‘let’ is preferred in most situation while declaring a variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Variable naming

A

Please use Camel Casing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

String concatenate

A

Just use ‘+’ sign between your strings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

String length

A

string.length;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Slicing and Extracting parts of String

A

string.slice( x , y )

x - the start of slicing, the string starting from zero (always keep in mind)
y - index of character upto which we should cut, not including that particular character.

Example - let a = “Koolaid”;

a.slice(4, 7) - Output —-> aid

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Arithematic

A

+, -, *, /, %

% - remainder

++ increament
– decreament

Math.round( ) ————> Generate random number from 0 to 0.99

Math.floor( ) —————> Rounds down a number to nearest lower integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Function call and Return

A
function functionName( (argument) )
{
        code here;
        return some-variable-here;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Random Number

A

Random number between 1 and 5

Math.floor( Math.random( ) * 5 + 1 );

math.random( ) * 5 —–> generates a number from 0 to 4.99

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Conditional statements and Comparators

A

If{ } else { }

comparators are ‘ < ‘ , ‘ > ‘, ‘ === ‘, ‘ <= ‘, ‘ >= ‘, ‘ !== ‘

’ == ‘ compares but doesnt comapre data type, and ‘ === ‘ compares the value as well as data types.

Combine conditions using ‘ && ‘, ‘ || ‘, ‘ ! ‘ (not).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Array

A

a= [1, 2, 3, 4, 5, 6];
a=[ ];

a[2] = 3;
because, arrays and strings start index from zero, 0.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Looping

A

while ( condition -> true ) { Loops code executes; }

for ( var initial, var conditional, var increment ) { Loop code here; }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly