E questions Flashcards

(74 cards)

1
Q

What is event bubbling?

A

when an event which triggers an event handler located on a child component also triggers an event handler on the parent component - the opposite of this is event capturing

For example, if the user clicks a hyperlink, that click event would pass through the <p> element containing the link, the </p> element, the element, and the document node.

You could put an alert on each one of these elements and the first alert would be on the link, then on the p, then on the body.

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

*What is the difference between let, const, and var?

A

var - the option before ES6, either local or global depending on where it’s declared, is hoisted (initialized as undefined), can be accidentally or unintentionally redefined

let - block scoped, cannot be redeclared in the same block but can be updated, can be redeclared in different blocks (will act as different variables)
is hoisted but not initialized

const - maintains constant value, block scoped, cannot be updated or redeclared but slightly different when it comes to objects where you can update individual key/values but not the entire object

var declarations are globally scoped or function scoped while let and const are block scoped.
var variables can be updated and re-declared within its scope; let variables can be updated but not re-declared; const variables can neither be updated nor re-declared.
They are all hoisted to the top of their scope. But while var variables are initialized with undefined, let and const variables are not initialized.
While var and let can be declared without being initialized, const must be initialized during declaration

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

What is variable scope?

A

scope is the range in which a variable is accessible in the context of the code. Local variables are defined within a function, global variables are declared outside of a function. block scope is a type of local scope and is anything within curly brackets like if etc does not create a new scope (only const and let). Lexical scoping is when a nested function has access to the outer functions variables, javascript uses this. Does not work the other way around.

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

What is a closure?

A

A function within another function, the inner function is the closure and is usually returned. Benefits - make it easier to control side effects, make it easier to create private variables.

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

PHP what is private vs protected?

A

A private constant, property, or method can only be accessed from within the class that defines it. A protected constant, property or method can only be accesed from within the class that defines it, or a descendant (inherting and parent) of that class. A public constant, property, or method can be accessed from anywhere.

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

*Difference between == and ===

A

both are comparison operators
=== compares both type and value, strict, does not try to convert values
== only compares value, not type. converts both to the same type to compare

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

*difference between let and const

A

let can reassign as many times are you want and/or change the type
const after the first assignment of value, you cannot reassign or modify - better to use const so you don’t unintentionally reassign a variable. you can change things within a const object or array, but you can’t change it completely.

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

*what is the use of arrow functions?

A

more concise way to write a function expression

traditional expression 
function (a, b){
   return a + b + 100; 
}
arrow function 
(a, b) => a + b + 100;

arrow functions cannot bind or use ‘this’

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

Difference between function declaration and function expression

A
function declaration- 
alert(foo()); // Alerts 5. Declarations are loaded before any code can run.
function foo() { return 5; } 
has global scope, cannot pass into another function 
function expression - 
alert(foo()); // ERROR! foo wasn't loaded yet
var foo = function() { return 5; } 

anonymous function stored to a variable - has variable/limited scope, can only be called after creation, can pass into another function

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

what is a promise and why do we use it?

A

Promises are JavaScript objects that represent an eventual completion or failure of an asynchronous operation. A promise is a returned object where you attach callbacks, instead of passing callbacks into a function. the place where you attach the callback after a successful completion of a task is called, . then().

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

what is a promise and why do we use it?

A

Promises are JavaScript objects that represent an eventual completion or failure of an asynchronous operation. A promise is a returned object where you attach callbacks, instead of passing callbacks into a function. the place where you attach the callback after a successful completion of a task is called, . then().

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

what is setTimeOut()

A

When you add setTimeOut it will make a function asynchronous - so it will execute after everything on a stack completes before it runs, even if the timing is set to 0

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

What is a closure and how do you use it?

A

A closure can be any function within another function, it’s key characteristic is that it has access to the scope of the parent function including it’s variables and method. Also has the potential for a function to have private variables. Positive - allows you to separate concerns very cleanly. Can also use it to implement throttling and debouncing.

const add = (function () {
      let counter = 0;
       return function () {
counter += 1; return counter
}
})();

add();
add();
add();

// the counter is now 3

If a function returns another function, the returned functions also hold on to the original variables from the first function. It is a way of keeping access to variables in a function after that function as returned. Disadvantages - variables used by closure will not be garbage collected, memory snapshot of the application will be increased if closures are not used properly.

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

What are Javascript events

A

An event is a process that allows you to react when certain things happen on a page. event -> action
inline events -> onclick
addEventListener -> most imporant

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

arrow function vs regular function

A
// Regular Function Syntax ES5:
var add = function(x, y) {
  return x + y;
};
// Arrow function ES6
let add = (x, y) => { return x + y };

Function expressions are best for object methods. Arrow functions are best for callbacks or methods like map, reduce, or forEach.

Arrow functions - lexical scoping

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

**PHP - What is the difference between Echo and Print

A

both are PHP statements used to display data output to the screen.

  1. echo does not return a value whereas print does return a value of 1 (which allows print to be used in expressions) echo is faster than print
  2. echo can accept multiple parameters, while print can only take in a single argument.

print_r works for arrays where echo only prints “array”

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

PHP difference between $var and $$var

A

$var is a simple variable

$$var is a reference variable

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

*PHP what are the differences between require and include.

A

Require and include both are used to include PHP script from one file to another file.

Require says a page must be developed - if it’s missing or has a wrong name there is a fatal error which stops the execution of the script.

A good case for require is in cases where a database connection file is involved and helps alleviate the possibility of multiple instances of the same file being included several times.

Include also expects a page to be developed, but will show a warning error and then continue to run the script.

include_once()
include

require_once()
require

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

What are the different types of errors in PHP

A
  1. notice error - when a variable is undefined
  2. warning - gives permission to execute the script but shows a warning message meaning a potential error is present.
  3. fatal - critical error, stops the execution of the script
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

PHP What is the difference between unlink and unset

A

Unlink() is used to delete files while Unset() makes a variable undefined.

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

PHP How can we get the properties of the browser?

A

$_SERVER[‘HTTP_USER_AGENT’] global variable is used to access browser properties

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

What is the maximum file size that can be uploaded in PHP and how can we increase it?

A

By default the max size of a file that can be uploaded is 2MB. You can change the max uploaded size value inside of php.ini file and set the value upload_max_filesize = 5M and restart all services.

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

PHP How do we get the value of the current session id?

A

The session_id() function is used to get the current session id. It returns the session id for the current session.

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

Is multiple inheritance supported in PHP?

A

No, multiple inheritance is not supported.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is a composer in PHP?
an application-level package manager for PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
26
How to get length of an array in PHP?
PHP count function echo count($array)
27
What is PECL?
PECL online directory for all of the known php extensions. it also provides hosting facilities for downloading and development of PHP extensions.
28
How to get the IP address of the client/user in PHP
You can use the $_SERVER['REMOTE_ADDR'] or $_SERVER['HTTP_CLIENT_IP'] to get IP address of user/client in PHP, but sometimes it may not return the true IP
29
*What are sessions and cookies in PHP?
A session stores the value on the server and cookies store the value in the users browser. Sessions are global variables that are stored on the server in the architecture. Every single session is tagged with a unique server ID that is later used to work with the storage and retreival of values Cookies are entities use to id unique users in the architecture. It is a small file that the server plants into the client system. This is done to get useful information from the client for the development of various aspects of the server.
30
PHP - What is zend engine?
Zend engine is used internally by PHP as a compilier and runtime engine. PHP scripts are loaded into memory and compiles into Zend OPcodes. The Zend engine provides memory and resource management and other standard services for the php language. Its performance, reliability, and extensibility have played a significant role in PHP's increasing popularity.
31
PHP -What are magic methods?
Magic methods are member functions that are available to all the instances of a class. Magic methods always start with '_'. All magic methods need to be declared as public. ``` _construct() _destruct() _set() _get() _call() _toString() ```
32
PHP What is the difference between Mysql_fetch_object and Mysql_fetch_array
MySQL fetch object will collect first single matching record | MySQL fetch array will collect all matching records from the table in an array
33
Difference between PHP4 and PHP5
PHP4 cannot support oops concepts, zend engine 1 | PHP5 supports oops concepts, zend engine 2
34
Which function is used in PHP to check the data type of any variable
gettype() function is used to check the data type of any variable. in javascript typeof()
35
How can you declare a constant variable in PHP
define() function is used to declare a constant variable. Declared without $ in front of it. Ex. define("PI", 3.14);
36
What are the global variables in PHP?
$_Request, $_Post, $_Get
37
PHP - how to redirect a web page
Use header method ex. header("location: demo1.php") - will pull info from that file into your current page, if @header it will hide any errors from the customer
38
PHP what is var_dump()
``` The var_dump() function is used to dump information about a variable. This function displays structured information such as type and value of the given variable ex. bool(true) ```
39
*What is the use of the header() function in PHP
1. used to redirect from one page to another header("Location: index.php"); 2. used to send an HTTP status code header("HTTP/1.0 this Not Found"); 3. used to send a raw http header header('Content-Type: application/json');
40
PHP What are traits?
Traits are a mechanism that provides some of the reuse advantages of multiple inheritances in languages like PHP, where multiple inheritances is not supported. Traits enable developers to reuse combinations of methods from different class hierarchies.
41
What is PEAR in PHP?
PHP Exension and Application Repository - a framework and repository for reusable php components. PEAR is a code repository containing all kinds of PHP code snippets and libraries. PEAR also offers a command ine interface that can be used to automatically install packages
42
How can you tell if a number is even or odd without using any condition or loop?
$arr=array("0"=>"Even","1"=>"Odd"); $check=13; echo "Your number is: ".$arr[$check%2]; use a modulo
43
Write a sample of code showing the nested ternary conditional operator in PHP.
$number_class = $number == 0 ? 'blue' : ($number > 0 ? 'green' : 'red');
44
What is strpos()?
The strpos() function finds the position of the first occurrence of a string inside another string. Note: The strpos() function is case-sensitive.
45
What is PDO?
PHP Data Objects a lightweight PHP extension that uses a consistence interface for accessing the database. Using PDO, a developer can easily switch from one database to another. But it does not support all the new features of the new MySql server.
46
**PHP what is meant by public, private, protected, static, and final scopes?
``` Public - variables, classes, and methods which are declared as public can be accessed from anywhere Private - variables, classes, and methods which are declared private can be accessed by the parent class only Protected - variables, classes and mothods which are declared protected can be accessed by the parent and child classes only Static - the variable which is declared static can keep the value after losing the scope Final - this scope prevents the child class to declare the same item again. ```
47
Which function is used in PHP to delete a file?
unlink()
48
Why do we use PHP? Advantages/disadvantages
There are several benefits to using PHP. 1) totally free and open source 2) platform independent - can run on Mac, Linux, Windows etc. 3) has flexibility to combine with many other programming languages 4) popularity 5) has built in database connection models 6) allows developers to use MVC architecture 7) automate common web development tasks like caching, session management, authentication, and url mapping. Disadvantages 1) it's not super secure due to being open source - the ASCII files are often easily available 2) utilizes a weak type 3) poor quality of error handling - no debugging tools 4) programmers need to learn PHP frameworks in order to efficiently use PHP.
49
What is Bedrock (Expensify)?
Bedrock was built by Expensify, and is a networking and distributed transaction layer built atop SQLite, the fastest, most reliable, and most widely distributed database in the world. Designed for geo-replication. Built on top of SQLite, compatible with MySql. Bedrock’s primary feature is its ability to seamlessly synchronize data between multiple nodes, manage distributed commits across those nodes, and automatically failover (and recover) in response to failure. This enables for very reliable configurations across multiple datacenters (or availability zones). A general description of how this works follows: Bedrock is simple. This means it exposes the fewest knobs necessary, with appropriate defaults at every layer. Bedrock is modular. This means its functionality is packaged into separate “plugins” that are decoupled and independently maintainable. Bedrock is WAN-replicated. This means it is designed to endure the myriad real-world problems that occur across slow, unreliable internet connections. Bedrock is Blockchain-based. This means it uses a private blockchain to synchronize and self organize. Bedrock is a data foundation. This means it is not just a simple database that responds to queries, but rather a platform on which data-processing applications (like databases, job queues, caches, etc) can be built. Bedrock is for global-scale applications. This means it is built to be deployed in a geo-redundant fashion spanning many datacenters around the world.
50
Difference between scaling out and scaling up?
Scaling out is adding more equivalently functional components in parallel to spread out a load. This would be going from two load-balanced web server instances to three instances. Scaling up, in contrast, is making a component larger or faster to handle a greater load.
51
Difference between MySQL and Bedrock
While MySQL is optimized for single-datacenter operation with light use of stored procedures, Bedrock is designed from the ground up to operate in a multi-datacenter environment with rigorous use of stored procedures – the new standard for modern application design.
52
CSS - What is box-model?
Essentially a box that wraps around every HTML element. It consists of margins, borders, padding, and the actual content. Margin -> border -> padding -> content
53
CSS - What is specificity?
1. the last (furthest down on css page) declared style takes precedence. 2. style attribute (inline) -> ID -> class -> element
54
PHP - why is webhosting so cheap?
PHP uses ZERO CPU and ZERO RAM when not serving requests. It is “scale to zero” by design.
55
CSS - What is the difference between static, relative, absolute, and fixed position
Static - default value, all elements are in order as they appear in the document Relative - the element is positioned relative to it's normal position (itself) Absolute - the element is positioned absolutely to its first positioned parent also removed from the flow of elements on the page Fixed - the element is positioned relative to the browser window, viewport - does not change when the window is scrolled.
56
CSS - difference between visibility: hidden and display: none
Visibility hidden still shows the same space that the element occupied. Display none removes both the element and the space.
57
What programming languages do you prefer to work with, and why?
Javascript, PHP, CSS/HTML
58
How would you explain API's to non-technical stakeholders?
An API (application programming interface) tells programmers how to automate a product - anything from web apps like Twitter, all the way down to Windows itself. For example, I could use Twitter's API to fetch our companies most recent tweets and display them on our website. That way our social media specialist can simply tweet without having to take extra steps to copy the tweet on our website. A set of rules (code) and specifications that software programs can follow in order to communicate.
59
What do you think are the most important aspects to pay attention to when reviewing another team members code?
I first look for security, functionality, and readability. Code simplicity is important to me as it makes the program more readable, as opposed to the code looking cluttered or being inefficient. I check for any weaknesses that could cause vulnerabilities and confirm that regulatory requirements have been met. The software passes automated and manual testing Code follows applicable conventions and is easy to understand. Code is not duplicated Blocks of code inside loops are as small as possible No memory leaks
60
Are you familiar with Agile? What has your experience been like as part of an agile software development process, if any?
The Manifesto for Agile Software Development outlines an approach based on iterations rather than a waterfall model. Requirements and solutions are generated through the collaboration of self-organizing and cross-functional teams and their end users. Among other things, it encourages a flexible planning style and a rapid response to change
61
Please explain big O notation in the simplest terms
Big-O notation is used in computer science to describe the performance or complexity of an algorithm. It describes how the runtime or space requirement of a function grows as an output grows.
62
Four major characteristics of OOP
Object-oriented programming has four basic concepts: encapsulation, abstraction, inheritance and polymorphism
63
Difference between class and object
Class is a blueprint or template from which objects are created. Object is a real world entity such as pen, laptop, mobile, bed, keyboard, mouse, chair etc. Class is a group of similar objects. Object is a physical entity.
64
What is a method
JavaScript methods are actions that can be performed on objects. A JavaScript method is a property containing a function definition.
65
What is a class vs a static method
static methods are called on a class, not on an instance of the class
66
What is a constructor
A constructor is a function that creates an instance of a class which is typically called an “object”. In JavaScript, a constructor gets called when you declare an object using the new keyword. The purpose of a constructor is to create an object and set values if there are any object properties present.
67
What is the difference between get and post
Both methods are used in HTTP requests, generally get is to download data and post is to upload but we can do both downloading as well as uploading either by get/post. Get sends parameters in url, post send parameters in the body section of a request. Post is more private and allows you to send more data. Get is faster without any parameters to receive data from an API.
68
Explain the difference between stateless and stateful protocols, which type of protocol is HTTP? Explain
Stateless protocol treats each request as an independent transaction. Does not require the server to retain any session, id, or status information. Stateful protocol is where the responder maintains state information (session data, id, status, etc) across multiple requests HTTP at its core is stateless. But some web servers implement state using different methods, like cookies, custom headers, etc.
69
What is doctype in HTML
Doctype tells the browser which version of HTML standard is used and how to render the page via language-specific specifications
70
What is SVG
scalable vector graphics - do not lose quality when we zoom in or out, easily customizable
71
Difference between session storage and localstorage
session storage is only available when the window or tab is open local storage is available even after closing and opening the browser window.
72
New features of HTML 5
header, nav, section, footer, aside, article - more semantic html new form controls - email, url, date, calendar
73
What happens when you type a URL in the browser and press enter?
1. You type maps.google.com into the address bar of your browser. 2. The browser checks the cache for a DNS record to find the corresponding IP address of maps.google.com. 3. If the requested URL is not in the cache, ISP’s DNS server initiates a DNS query to find the IP address of the server that hosts maps.google.com. 4. The browser initiates a TCP connection with the server. 5. The browser sends an HTTP request to the webserver. 6. The server handles the request and sends back an HTTP response. 7. The browser displays the HTML content (for HTML responses, which is the most common).
74
Types of error messages
● 1xx indicates an informational message only ● 2xx indicates success of some kind ● 3xx redirects the client to another URL ● 4xx indicates an error on the client’s part ● 5xx indicates an error on the server’s part