-
Notifications
You must be signed in to change notification settings - Fork 9
Frontendquestions #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
8a7f57d
7c01767
b01ae36
1c4b173
92157e5
550c68c
ef354b0
7bb920f
a4bf78d
3002d9d
0cbeccf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| 1. [ Native Javascript Questions ](/Web-Development/NativeJavascript/questions.md) | ||
| 2. [ Native Javascript Answers ](/Web-Development/NativeJavascript/answers.md) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Answers to the frontend questions Native script | ||
| 1. | ||
| ``` | ||
| function sum(){ | ||
| let | ||
| sumOfArgs=0, | ||
| i=0; | ||
| for(;i<arguments.length;i++){ | ||
| sumOfArgs+=arguments[i]; | ||
| } | ||
| return sumOfArgs | ||
| } | ||
| ``` | ||
| 2. Inheritance works differently in javascript not like in other languages, here we have parent object set in the prototype properties of the object which it refers if it does not find the current object. It will be a chain of references to parent objects in case of multiple inheritances so it is called prototype chain. | ||
|
||
| 3. Closures in javascript are the block of code and the variables used in it are bound to the block through the variables are defined in its parent object. | ||
|
||
| 4. `var` variables are hoisted prior to the variables are executed but `const` and `let` or not. And simple properties defined by `const` cannot be changed. | ||
|
||
| 5. b will be `undefined` as only the variables are hoisted but not the assignment. | ||
|
||
| 6. We know javascript is single threaded but the browser is not. The browser will have javascript engine thread and network thread, so when a network request is completed from network thread which is running parallelly to javascript engine thread and the javascript engine will execute the network request callback once it finishes its request. | ||
|
||
| 7. Promises make syntax easier and are the best way to handle asynchronous functions. We can do that with callback but when there is a chain of asynchronous functions it is difficult to handle there. | ||
|
||
| 8. React more developer friendly and Angular build on solid software principles like MVC and dependency injection. | ||
|
||
| 9. Browsers are providing options to throttle networks so we can customize the speed of a network. | ||
|
||
| 10. `use strict` helps the developers to write javascript in a secured way and throw errors if they are any undeclared variables. | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Native Javascript | ||
| 1. Write a function which can add all the arguments and return the value ? | ||
| Sample Inputs / Outputs | ||
| ``` | ||
| sum(1,2) => 3 | ||
| sum(1,2,.3) => 3.3 | ||
|
|
||
| ``` | ||
| 2. Explain the prototypal inheritance? | ||
| 3. Explain the closures? | ||
| 4. Difference between `var` ,`let` & `const` ? | ||
| 5. What would be the output of the following code? | ||
| ``` | ||
| function a(){ | ||
| console.log(b); | ||
| } | ||
| var b=6; | ||
|
|
||
| ``` | ||
| 6. How the javascript engine and Browser handles asynchronous calls | ||
| 7. Difference between callbacks and promises? | ||
| 8. Which one do you prefer among React and Angular? | ||
| 9. How do you simulate the low speed networks? | ||
| 10. Why the `use strict` is used? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more ES6 way of doing things would be
or
Using arguments is not considered a good practice anymore.