Fundamentals Flashcards

1
Q

Explain Lexicalscoping

A

Refers to scope which uses location for name resolution. In other words the scope of a reference is determined by the location of the declaration.

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

What is a Scope

A

Where a given name can reference a given construct such as a variable.

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

Explain Hoisting in JavaScript.

A

Hoisting in JavaScript is a behaviour where declaration are all moved to the top of the current scope. Such as the current script or function.

Thus the ‘use strict’ mode to force you to declare variables before use.

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

What bugs can result from hoisting?

A

It moves up declaration but not the initiation so if the variable is used , it can result in a undefined error.

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

What is not allowed in strict use mode?

A

Using variables without declaration

Objects are variables too

Using objects without declaring it, it is not allowed.

Deleting a variable ( or objects) is not allowed.

Deleting a function is not allowed.

Duplicating a parameter name is not allowed.

Octal numeric literals not allowed.

Writing to a read-only property is not allowed:

"Use strict";  
var objects = {}; Object.defineProperty(objects, "X", { value: 0, writable:false}); 
Obj.x = 3.14;

Writing to a get-only property is not allowed:

Deleting an undeletable property is not allowed.

The string “eval” cannot be used as a variable:

The string “argument” cannot be used as a variable.

The with statement is not allowed.

For security reasons , eval() is not allowed to create variable in the scope from which it was called:

In function calls like f() , this value was the global object in strict mode , it is now undefined.

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

What is the key difference between textContent and innerText?

A

textContentgets the content of all elements, includingand<style>elements. In contrast,innerTextonly shows “human-readable” elements.</style>

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

What is the purpose of using anonymous functions?

A

Because all functions are global by default, there is a danger of overwritting previously function This can however be prevented if you make the function local. This is done by encasing code in a function which is is encased in parenthesis and is known as anonymous functions.

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

What are partial and curry application

What’s the difference?

A

Partial application is process where only some of its argument s get applied . The partially applied function gets returned for later use.

It fixes one or two argument s inside the return ed function and the return ed function takes the remaining parameters as argument in order to complete the function application.

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

What is Promise?

A

A promise object that may produce a single value some time in the future: either a resolved value, or a reason that it’s not resolved.
It is in 3 states fulfilled , rejected or pending. A callback to handle the fullfilled value or the reason for rejection.

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

What are the applications of bind, calls and apply in function calls?

A

Use.bind()when you want that function to later be called with a certain context, useful in events. Use.call()or.apply()when you want to invoke the function immediately, with modification of the context.

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

What happens when pop is used in an empty array?

A

POP returns undefined.

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

What is the purpose of push?

A

Push such as array.push a new value to the end of array.

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

What is a shift method?

A

Shift is used to add one element to the start of an array. It will remove the value in first item
.

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

What is unshift

A

It will remove the first element in the array and shift the other values to the left.
It will shorten the array length.

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

What is the purpose of the delete function?

A

It will remove the value located in similar index provided in the delete argument.
Advice not to use.

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

Explain the anonymous functions

A

Anonymous functions are useful for accessing code written by other functions. To help avoid global scope, wrapping code or function in another one so the calling function becomes a private function.
It normally ends with parenthesis or if you reference it as variables.

17
Q

What is local storage?

A

In javascript 5 it is Store of name, value pairs available to JavaScript.
There are no path settings, no settings on amount used .
We have sessionStorage is unique to current lotation ( to tab )

Local storage is linked to permanent storage.
Key returns index , clear - wipes it clean , remove

17
Q

What is local storage?

A

In javascript 5 it is Store of name, value pairs available to JavaScript.
There are no path settings, no settings on amount used .
We have sessionStorage is unique to current lotation ( to tab )

Local storage is linked to permanent storage.
Key returns index , clear - wipes it clean , remove

17
Q

What is local storage?

A

In javascript 5 it is Store of name, value pairs available to JavaScript.
There are no path settings, no settings on amount used .
We have sessionStorage is unique to current lotation ( to tab )

Local storage is linked to permanent storage.
Key returns index , clear - wipes it clean , remove

17
Q

What is local storage?

A

In javascript 5 it is Store of name, value pairs available to JavaScript.
There are no path settings, no settings on amount used .
We have sessionStorage is unique to current lotation ( to tab )

Local storage is linked to permanent storage.
Key returns index , clear - wipes it clean , remove

17
Q

What is local storage?

A

In javascript 5 it is Store of name, value pairs available to JavaScript.
There are no path settings, no settings on amount used .
We have sessionStorage is unique to current lotation ( to tab )

Local storage is linked to permanent storage.
Key returns index , clear

18
Q

What is local storage?

A

In javascript 5 it is Store of name, value pairs available to JavaScript.
There are no path settings, no settings on amount used .
We have sessionStorage is unique to current lotation ( to tab )

Local storage is linked to permanent storage.
Key returns index , clear - wipes it clean , remove

19
Q

What is the difference between sessionStorage and Local storage.

A

In javascript 5 it is Store of name, value pairs available to JavaScript.
There are no path settings, no settings on amount used .
We have sessionStorage is unique to current lotation ( to tab )

Local storage is linked to permanent storage.
Key returns index , clear - wipeIre it clean , remove I

20
Q

How do you import Java code over to another file?

A

Use export modules =

21
Q

How do you handle events in a web page?

A

Add an addEventListener

This takes an event type , a function literal and false

22
Q

What is advantage of using addEventListener

A

Used for handling multiple events within a single calls or event propitiation.
Events can be triggered by non Dom elements you can then write your own events and different parts of your code can listen for them.

23
Q

One main disadvantage of addEventListener?

A

It is not compatible with browsers older than i.e 8

24
Q

What is the signature of a call function?

A

Call takes the first argument of the function as this while passing the rest to the invoking function.

Some function.call( this.a , b, c , d)
                 Return function(  b, c , d)
25
Q

What is the apply function signature?

A

It takes all the other arguments after the first as an arrays.

some function.apply(this.a, [b, c, d,]

26
Q

What is the method signature used to convert a string to an Integer in JavaScript?

A

parseInt( , radix )

27
Q

How do you convert a string to a float?

A

Use the parseFloat(< string> ) method.