FE Set

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What is the value of the variable eventPrice after the following code runs? let event = { name: 'a', financials: { baseCost: "$19.99", dicount: false, maxCost: "$29.99" }, sunscribers: {} } let eventPrice; const assignEvent = ({financials:{baseCost:price}})=> eventPrice = price assignEvent(event)

"$19.99"

Output? const my = new Array(2) my[1] = 1 my[3] = 3 console.log('Length:', my.length) console.log('Elements:') for (const element of my) { console.log('\t', element) }

"Length:", 4 "Elements:" " ", undefined " ", 1 " ", undefined " ", 3

x = {'foo': 'bar'}, y={'baz':x}, z = y['baz']['foo'] print z value

'bar'

Output: let x = 'fog'; function first() { console.log(x) } x = 'dog'; function second() { let x = 'log' first(); } second()

'dog'

Output? function* gen1() { console.log(yield 1) console.log(yield 2) console.log(yield 3) } const iterator = gen1() console.log(iterator.next('a').value) console.log(iterator.next('b').value) console.log(iterator.next('c').value)

1 "b" 2 "c" 3

Output? const obj = { prop: 1 } console.log(obj.prop) Object.defineProperty(obj,'prop',{ writable: false, value: 2 }) console.log(obj.prop) obj.prop = 3 console.log(obj.prop)

1 2 2

x = matrix[0][2] + matrix[2][1]

11

what is the value of g after the following code bloack runs ? function f(x) { x *= 2; return function(y) { y *= x; return function(z) { return z * y; } } } let g = f(3)(4)(5)

120

what is the value of g after the following code block runs ? const f = n => n <= 1 ? 1: n*f(n-1); let g = f(4);

24 -------------------------------------------------------------- if(n<=1){ return 1 } else{ return n*f(n-1) }

Value of x = f(4)

7

When browser don't support a new feature, developers turn to polyfills. How do these work ?

A polyfill implements an API so that developers can build against an consitent interface, even on unsupported browsers.

To create web apps that can gracefully handle a lost network connection and sync data in a background thread after the device comes back online, you should use

A service worker ======================================================== The Background Synchronization API provides a way to defer tasks to be run in a service worker until the user has a stable network connection.

Which type of testing would best measure which version of a landing page results in more sign-ups ?

A/B Testing

Which of the following decribes the relationship between a Promise and async/await ?

Async/await is syntactic sugar for Promises that allows you to write synchronous-looking callback code

Instagram scroll a vertical feed

At the root, tableview.

Finance app

Core data

UI Components reusable

Custom view controller class

What is typical benefit of a client using GraphQL API over REST API ?

Fethcing multiple resources per request

Frame and bounds

Frame size and location of the view coordinate system bound is the same information in its own coordinate system

Http request method shouldn't alter the state of the server

GET

Which of the following HTTP request methods should not alter the state of the server?

GET

Which of the following is used to maintain a user's logged-in state as they browse multiple pages on a website?

HTTP cookies

Return index

If array_element == element {return i}

Which of the following client-side storage APIs (when supported by the browser) are accesible by Service Workers ?

IndexedDB, Cache ======================================================== IndexedDB and the Cache Storage API are supported in every modern browser. They're both asynchronous, and will not block the main thread. They're accessible from the window object, web workers, and service workers, making it easy to use them anywhere in your code.

An HTTP server is working as expected when serving local requests. but is not accepting external requests. What is a likely cause?

It is binding to address 0.0.0.0 -------------------------------------------------------------- https://serverfault.com/questions/78048/whats-the-difference-between-ip-address-0-0-0-0-and-127-0-0-1

What is the layer property on UIView object

It is the view core animation layer used for rendering

Why catching used to increase read performance?

It makes the second and subsequent reads faster

Conver data recevied is a string containing a JSON object. How do you convet this string into a Javascript object ?

JSON.parse()

function foo(){ function bar() { setTimeout( ()=> console.log('Curly'), 1000); } console.log('Larry'); return bar; } let x = foo(); x(); console.log('Moe');

Larry,Moe,Culy

Sorted list

Makes no sense

Extensión

Methods

Suppose we have a page with the following style and a handful of empty divs with class pink. What is rendered on the page ? <style> .pink { backgroundcolor: pink; display: inline-block; margin: 10px; height: 100px; width: 100px; } </style>

Pink square stacked horizontally

FindIndexOfMin

Right after line 8 set minValue to val

What kind of SQL statement retrieves data from a table?

SELECT

Which of the following startagies should we usse to efficiently serve static asset to users around the globe?

Serve assets from a CDN to leverage their infrastructure.

Output? const s = new Set(); let ar = [5,6,7]; let obj = {name:'kelvin'}; s.add(1) s.add(1) s.add('a') s.add('a') s.add(undefined) s.add(undefined) s.add(null) s.add(null) s.add(ar) s.add(ar) s.add(obj) s.add(obj) console.log(s,s.size)

Set(6) { 0: 1 1: "a" 2: undefined 3: null 4: Array(3)value: (3) [5, 6, 7] 5:value: {name: 'kelvin'} size: 6 } 6

Output? const s = new Set() s.add(1) s.add(1) s.add('a') s.add('a') s.add(undefined) s.add(undefined) s.add(null) s.add(null) s.add({}) s.add({}) s.add([1,2,3]) s.add([1,2,3]) console.log(s,s.size)

Set(8) { 0: 1 1: "a" 2: undefined 3: null 4: Object 5: Object 6: Array(3) 7: Array(3) } 8 -------------------------------------------------------------- except object and array everything else will be discarded when added multiple times.

Music Editing app. Once a composition is done the app encodes it (asynchronously)

The important thing here is that we separate the UI update from the actual encoding logic.

When testing website against your api. you get the following error: "Origin http://localhost:8000 is not allowed by Access-Control-Allow-Origin" Why does this occur ?

The same-origin policy restricts how scripts interact with resources on another origin. Make sure your API allows cross-origin requets. ------------------------------------------------------------- Ex 1: your domain is example.com and you want to make a request to test.com => you cannot. Ex 2: your domain is example.com and you want to make a request to inner.example.com => you cannot. Ex 3: your domain is example.com:80 and you want to make a request to example.com:81 => you cannot EX 4: your domain is example.com and you want to make a request to example.com => you can. more info here: https://stackoverflow.com/questions/9310112/why-am-i-seeing-an-origin-is-not-allowed-by-access-control-allow-origin-error

What is the syntax for an async, generator, arrow function ?

There is no syntaxt for a function that is both an arrow function and a generator function

Why are more developers using new style sheet languages like LESS and SASS instead of CSS ?

They compile to CSS, but provide convinient syntax for nesting, variables, and other features.

Which is na example of a "multipart" MIME type ?

Web fonts ======================================================== https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

How do Webpack and Babel differ ?

Webpack is a module bundler. whereas Babel is a Javascript compiler

which one is sortable ISO 8602 standart in UTC?

YYYY-MM-DDTHH:mm:ssZ Z stands for UTC

When using webSocket.send(), how do you know the data sent has been transmitted to the network

You can only know that the datat has been transmitted when the server sends a message back to confirm delivery.

You have a web app that allows users to chat with their friends. The app uses Websockets to send text data. You would lie to add a feature to aloow user to send binary diles as "blobs". Which of the following statements is true ?

You existing Websocket can send and receive both text and binary formats, but you have to check the type with instaceof when receiving incoming messages.

output? function myFN(y1,y2,...y3){ const [x1,...[result1,result2] ]= y3 console.log(y3, x1, result1, result2) } const myArray = ['a','b','c','d','e'] myFN(...myArray)

['c', 'd', 'e'] 'c' 'd' 'e'

What would be the output? const arr = []; try{ arr.push('try'); throw new Error(); }catch(e){ arr.push('catch') }finally{ arr.push('finally') } console.log(arr)

['try', 'catch', 'finally'] -------------------------------------------------------------- If you remove throw statement then: ['try', 'finally']

Output ? async function apiCall() { return new Promise(resolve => { setTimeout(() => { resolve('b') }, 50) }) } async function logger() { setTimeout(() => console.log('a'), 10) console.log(await apiCall()); console.log('c') } logger()

a b c

const a = 0; const b = ''; //missing line const outcome = !!(a||b||c||d)

const c = [false]

function FN(val1,val2,CB){ setTimeout(()=>{CB(val1+val2)},1) } const callbackToPromise = (cFN)=>(...args)=>{ return new Promise((resolve,reject)=>{ try{ cFN(...args,(...e)=>{resolve(e)}) }catch(error){ reject(error) } }) } const rFN = callbackToPromise(FN) rFN(1,2).then(([v])=>console.log(v))

const callbacltoPromise = (asyncWithCallback)=>(...funcArgs)=>{ .... and so on

Suppose whe have a function f which takes 3 arguments. What happens when f is called with only 1 argument ?

f will be called with undefined values for the unspecified arguments.

In what order does f receive it;s arguments ? f("foo"); setTimeout( ()=>f("bar") , 0); f("baz")

foo baz bar

find a buggy code that prints : 1 2 'tempvalue' instead of: 1 2 when you usethe below code: let myarr = [1, 2] myarr.temp = 'tempvalue'

for (const i of myarr) { console.log(i) } -------------------------------------------------------------- Note: adding a custom prop won't change array length. for...in is mainly used for iterating over object keys. If you use it with an array it will go over some custom properties of that array as well.

Find a function that outputs true and true for the belwo code ? const m = Queue() m.en(1) m.en(2) console.log(m.dq()===1) console.log(m.dq()===2)

function Queue() { const qarr = [] return { en: qarr.push, dq: qarr.shift } }

catch undeclared variable

if (typeof TEST_ENV !== 'undefined') { console.log('In test env') } -------------------------------------------------------------- the only way to catch an undeclared variable is to use typeof

Which of the following styles will horizontally center a fixed-sized element inside its parent?

margin: auto;

def find_max(nums): https://youtu.be/7CYV0hOHAm0?t=35

max_num = num

Which technique will dramatically improve the performance of the following function ? func fib(n: Long): Long{ return if (n<=1) n else fib(n-1) + fib(n-2) }

memoization

In HTTP/1.1 pipelining is used to send multiple requests over the same connection with lower latency. In HTTP/2, it has been supported by which technique?

multiplexing

Cumulative sum

output.push(list[i] + output[i - 1]

function cumulative_sum(list) { let output = []; for (let i = 0; i < list.length; i++) { if (i == 0) { output.push(list[i]) } else { // Fill in the missing line here } } return output; }

output.push(list[i]+output[i-1])

function makeAdder(x){ // ??? } var add5 = makeAdder(5); var add8 = makeAdder(8); var add20 = makeAdder(20); assert(add5(10) === 15)

return function (y){ return x+y }

fill in the missing line of code: function strToFloat(str){ // ??? }

return parseFloat(str)

div { width: 50px; height: 100px; padding: 25px; } #elem1 { box-sizing: border-box; background-color: blue; } #elem2 { background-color: red; }

smaller blue box as the border will be subtracted from the total dimensions

const socket = new WebSocket('wss://example.com') function messageHandler(event){ console.log(event.data) }

socket.onmessage = messagehandler

which is not an accurate statement regarding the performance of matrix multuplication (of size n) ?

the basic algorithm runs in O(n^3) time.

When multiple, conflicting CSS rules match the same element,_______________ ....

the most specific rule is applied. ======================================================== When dealing with the specificity of a CSS rule,the more specific rule wins. So, if the selectors are the same, then the lastone wins, so the following example always defines H1 elements as green.

Which of the following is a primary goal of the OAuth standard ?

to grant third party access without giving them a password

Image view do catch

ui freezes while image download

Which of the last four variables contains the array ["chain","deo","grills"] as a value ?

w


संबंधित स्टडी सेट्स

cspp Chapter 20 -- Symmetric Encryption and Message Confidentiality -- Stallings 4th ed.

View Set

Psy 101 - Chapter 15 Psychological Disorders

View Set

Chapter 8 Security Strategies and Documentation

View Set

SERVSAFE EXAM CHAPTER 4 THE FLOW OF FOOD

View Set

Ovarian Torsion, Pelvic Congestion, RPOC, C-section

View Set

GI Embryology , Anatomy UWORLD Q&A

View Set

Blood Transfusions, CVAD, Enteral Tubes & Ostomy Care

View Set