https://github.com/mahboub99/every-day-learning
every-day-learning is a collection of questions and answers that i write down through my journey in learning ,here you might find various questions in front end , problem solving and programming languages
https://github.com/mahboub99/every-day-learning
Last synced: 11 months ago
JSON representation
every-day-learning is a collection of questions and answers that i write down through my journey in learning ,here you might find various questions in front end , problem solving and programming languages
- Host: GitHub
- URL: https://github.com/mahboub99/every-day-learning
- Owner: Mahboub99
- Created: 2021-01-30T16:26:30.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-06T14:13:13.000Z (almost 5 years ago)
- Last Synced: 2025-05-06T18:18:06.382Z (11 months ago)
- Homepage:
- Size: 38.1 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
every day learning
[](https://github.com/Mahboub99/every-day-Learning/contributors)
[](https://github.com/Mahboub99/every-day-Learning/issues)
[](https://github.com/Mahboub99/every-day-Learning/network)
[](https://github.com/Mahboub99/every-day-Learning/stargazers)
[](https://github.com/Mahboub99/every-day-Learning/blob/master/LICENSE)
## About
> every-day-learning is a collection of questions and answers that i write down through my journey in learning ,here you might find various questions in front end , problem solving and programming languages
### How can I export a directory structure in Windows?
>[Complete answer](https://superuser.com/questions/258287/how-can-i-export-a-directory-structure-in-windows).
``` shell
tree /f /a > tree.txt
```
### How to install vue CLI?
``` shell
npm install -g vue-cli
```
### How to create vue app?
```shell
vue create
```
### what is the difference betwen "data" and "props" in vue?
> [Complete answer](https://medium.com/javascript-in-plain-english/different-between-props-and-data-in-vue-components-d571cfa078e4).
>There’s a difference between props and data. Data is stored in the private memory of each component where we can store variables that we need. Props are passed in from the parent component to the child.
#### example passing data from parent to child as props:
child:
```vue
{{msg}}
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
```
parent:
```vue
import HelloWorld from './components/HelloWorld.vue'
export default {
name: 'App',
data(){
return{
title:"from app component"
}
},
components: {
HelloWorld
}
}
```
using `:msg="title"` to pass "title" as data not `string`
### what is the differance between `methods` and `computed` in vue ?
>[Complete answer](https://medium.com/notonlycss/the-difference-between-computed-and-methods-in-vue-js-9cb05c59ed98).
>In comparison, a method invocation will always run the function whenever a re-render happens but computed just calls whenever the data is updated.
| methods | computed |
|:-----------------------------------------------------------------------------------------:| :---------------------------------------------------------:|
| To call a function when an event happen in the DOM | You need to compose new data from existing data sources |
| To call a function from the computed or watchers when something happens in your component.| You need to reference a value directly in your template |
| You need to pass parameters | You call the same function more than once in your template |
### what is the diffrence between Primitive and Reverance value in js?
> [Complete answer](https://www.javascripttutorial.net/javascript-primitive-vs-reference-values).
>In JavaScript, a variable may store two types of values: primitive and reference.
JavaScript provides six primitive types as `undefined`, `null`, `boolean`, `number`, `string`, and `symbol` , and a reference type `object`(also `array`).
The size of a primitive value is fixed, therefore, JavaScript stores the primitive value on the `stack`.
On the other hand, the size of a reference value is dynamic so JavaScript stores the reference value on the `heap`.
### How to count the number of inversions in an array ?
> we can do it in `O(n^2)` the brute force solution
```
initialize arr to [1,2,4,3,5,6]
initialize i to 0
initialize inversions to 0
while i is less than length of arr
initialize j to i+1
while j is less than length of arr
if arr[i] is greater than arr[j]
then increment inversions by 1
print out inversions
```
>or we can use merge sort in `O(nlog(n))` devide and conquer algorithm.
```
function countInversions(array) {
if length of array is equal to 1
return array
midPoint = length of array \ 2
firstHalf, inversions1 = mergeSort(first half of the array)
secondHalf, inversions2 = mergeSort(second half of the array)
initialize sortedArray to an empty array
initialize i to 0
initialize j to 0
initialize inversions to 0
while i < length of firstHalf and j < length of secondHalf
if firstHalf[i] > secondHalf[j]
append secondHalf[j] to sortedArray
inversions = inversions + (midPoint - i)
else
append firstHalf[i] to sortedArray
append the remaining elements of firstHalf to sortedArray
append the remaining elements of secondHalf to sortedArray
totalInversions = inversions1 + inversions2 + inversions
return sortedArray, totalInversions
}
```
> [Complete answer](https://medium.com/the-andela-way/count-inversions-5fe3288f11fb).
>
### what is the Progressive web Apps?
> [Complete answer](https://web.dev/what-are-pwas/).