JavaScript Basic Flashcards

1
Q

What is JavaScript

A

a scripting or programming language that allows you to implement complex features on web page

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

Java vs JavaScript

A

Java code must be compiled, and JavaScript code is interpreted directly by a borwser
JavaScript code is run on a browser only, while Java creates applications that run in a virtual machine or browser.
Java is an OOP (object-oriented programming) language, and JavaScript is specifically an OOP scripting language.
Java Multithreaded, JavaScript is single threaded
Java is static type and JavaScript is dynamic type

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

Advantage of JavaScript

A

Client side no need for server

Dynamically typed

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

JavaScript Datatypes

A
Number
String
Boolean
Object
Undefined
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

== and ===

A

double compares value, triples compare datatype then value

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

XML

A

extensible markup language, rule for encoding documents in format that is human- readable and machine readable

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

Var

A

function scope

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

Let

A

Block scope

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

Const

A

block scope, only primitive is constant, can’t be changed once assigned. Need to be assigned when declared

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

Falsy Value

A

undefined, null,0 , false , NaN, ‘ ‘

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

Undefined

A

uninitialized variable

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

Synchronous

A

same waiter serve multiple table but waits for chef to finish before server another

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

Asynchronous Single threaded non-blocking

A

same waiter serving multiple table

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

Closures

A

Closure is a locally declared variable related to a function which stays in memory when the function has returned. (e.g nested function)

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

Promises

A

pending(initial state), fulfilled(operation success), rejected (operation failed), lets asynchronous method return values like synchronous method, instead of immediately returning the final value, it returns promise that it’ll supply the value in the future

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

Hoisting

A

move var variables & function declarations to the top

17
Q

Type Coercion

A

convert value from one type to another (e.g. string to number)

18
Q

This keyword

A

In method: owner object
Alone: global object
In a function: global object
Event: element that received the event

19
Q

Limitation of JavaScript

A

Client-side

Can’t be used for networking applications

20
Q

Is Undefine and Null equal?

A

Undefine and Null are equal in value but different in type

21
Q

What does NULL mean in JavaScript?

A

The NULL value is used to represent no value or no object

22
Q

Callbacks

A

Function passed as an argument to another function. Used when a function have to wait for another function.
- Used for Asynchronous function (e.g. making HTTP request)

23
Q

What does the async function do?

A

Make a function return a promise.