Javascript Flashcards

1
Q

Variable

A

“name storage” for data. Use ‘let’ to create a variable in Javascript. Variable is right after.

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

Show 2 variables coping data.

A

let hello = ‘hello world!’;
let message;

message = hello world;

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

How many times should a variable be declared ?

A

Once

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

Variable Limitations

A
  1. Name MUST contain letters, numbers or symbols $ and _

2. First character must not be a digit

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

Valid Variable Names

A
  1. let userName;
  2. let test123;
  3. let $;
    4 let _;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Does case matter ?

A

YES!!

apple and AppLE are two different variables.

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

Reserved names

A
let
class 
return
function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Use strict

A

Allow you not to use ‘let’, as long as you define to use strict.
Must put: “use strict”;

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

Constants

A

Declare a constant(UNCHANGING) variable, uses ‘const’ instead of ‘let’

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

Can ‘const’ be reassigned ?

A

NO!

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

Uppercase constants

A

used for difficult to remember values that are known prior to execution

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

When do you use uppercase constants?

A

When variable values never change. Ex. color codes, birthdays etc.

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

Infinity

A

is a special value that is greater than any number.

  • alert (1/0);
  • alert(Infinity);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How many special numeric values are there ?

A
  1. Infinity, -Infinity and NaN
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

NaN

A

represent a computational error. It is a result of a incorrect or undefined math operation

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

Number Data Type

A

Cant present integer values larger than 2(53_1) superscript or less than -(253-1) for neg.

17
Q

BigInt

A
represent integers of arbitrary length.appending n to the end of an integer:
const bigInt = 1234567890123456789012345678901234567890n;
18
Q

How many quotes are there in Javascript?

A
    • Double “Hello”
    • Single ‘Hello’
    • BackticksHello
19
Q

Backticks

A

“extended functionality” quotes. They allow us to embed variables and expressions into a string by wrapping them in ${…}

Ex:let name = “John”;

// embed a variable
alert( `Hello, ${name}!` ); // Hello, John!
// embed an expression
alert( `the result is ${1 + 2}` ); // the result is
20
Q

Boolean

A

has only two values: true and false.

This type is commonly used to store yes/no values: true means “yes, correct”, and false means “no, incorrect”.

21
Q

Null

A

null is not a “reference to a non-existing object” or a “null pointer” like in some other languages.

It’s just a special value which represents “nothing”, “empty” or “value unknown”.

22
Q

Undefined

A
23
Q

Undefined

A

“value is not assigned”.

If a variable is declared, but not assigned, then its value is undefined:

let age;

alert(age); // shows “undefined”

24
Q

Object

A
24
Q

Object

A

objects are used to store collections of data and more complex entities.

25
Q

Symbol

A

used to create unique identifiers for objects.

26
Q

Typeof operator

A

returns the type of the argument. It’s useful when we want to process values of different types differently or just want to do a quick check.

typeof undefined // “undefined”

typeof 0 // “number”

typeof 10n // “bigint”

typeof true // “boolean”

typeof “foo” // “string”

typeof Symbol(“id”) // “symbol”

27
Q

How many data types are there in Javascript?

A

8

  • number
  • bigint
  • string
  • boolean
  • null
  • undefined
  • object
  • symbol