Skip to content

Commit 2c18b88

Browse files
committed
fix some markdown syntax and mistypings
1 parent 319b807 commit 2c18b88

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

README.md

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -457,15 +457,17 @@ List of 300 VueJS Interview Questions
457457
5. splice()
458458
6. sort()
459459
7. reverse()
460+
460461
If you perform any of the above mutation method on the list then it triggers view update. For example, push method on array named 'items' trigger a view update,
461462
```javascript
462463
vm.todos.push({ message: 'Baz' })
463464
```
464-
13. ### What are the array detection non mutation methods?
465+
13. ### What are the array detection non-mutation methods?
465466
The methods which do not mutate the original array but always return a new array are called non-mutation methods. Below are the list of non-mutation methods,
466467
1. filter()
467468
2. concat()
468469
3. slice()
470+
469471
For example, lets take a todo list where it replaces the old array with new one based on status filter,
470472
```javascript
471473
vm.todos = vm.todos.filter(function (todo) {
@@ -478,13 +480,14 @@ List of 300 VueJS Interview Questions
478480

479481
1. When you directly set an item with the index,For example,
480482
```javascript
481-
vm.tods[indexOfTodo] = newTodo
483+
vm.todos[indexOfTodo] = newTodo
482484
```
483485
2. When you modify the length of the array, For example,
484486
```javascript
485487
vm.todos.length = todosLength
486488
```
487489
You can overcome both the caveats using `set` and `splice` methods, Let's see the solutions with an examples,
490+
488491
**First use case solution**
489492
```javascript
490493
// Vue.set
@@ -520,16 +523,16 @@ List of 300 VueJS Interview Questions
520523
email: john@email.com
521524
})
522525
```
523-
16. ### How do you use for directive with a range?
524-
You can also use integer type(say 'n') for v-for directive which repeat the element many times.
526+
16. ### How do you use v-for directive with a range?
527+
You can also use integer type(say 'n') for v-for directive which repeats the element many times.
525528
```javascript
526529
<div>
527530
<span v-for="n in 20">{{ n }} </span>
528531
</div>
529532
```
530533
It displays the number 1 to 20.
531-
17. ### How do you use for directive on template?
532-
Just similar to v-if directive on template, you can also use a <template> tag with v-for directive to render a block of multiple elements. Let's take a todo example,
534+
17. ### How do you use v-for directive on template?
535+
Just similar to v-if directive on template, you can also use a `<template>` tag with v-for directive to render a block of multiple elements. Let's take a todo example,
533536
```javascript
534537
<ul>
535538
<template v-for="todo in todos">
@@ -545,7 +548,6 @@ List of 300 VueJS Interview Questions
545548
Submit
546549
</button>
547550
548-
\\\\
549551
methods: {
550552
show: function (message, event) {
551553
// now we have access to the native event
@@ -562,23 +564,24 @@ List of 300 VueJS Interview Questions
562564
4. .self
563565
5. .once
564566
6. .passive
567+
565568
Let's take an example of stop modifier,
566-
```javascript
569+
```html
567570
<!-- the click event's propagation will be stopped -->
568571
<a v-on:click.stop="methodCall"></a>
569572
```
570573
You can also chain modifiers as below,
571-
```javascript
574+
```html
572575
<!-- modifiers can be chained -->
573576
<a v-on:click.stop.prevent="doThat"></a>
574577
```
575578
20. ### What are key modifiers?
576-
Vue supports key modifiers on `v-on` for handling keyboard events. Let's take an example of keyup event with enter keycode
577-
```javascript
579+
Vue supports key modifiers on `v-on` for handling keyboard events. Let's take an example of keyup event with enter keycode.
580+
```html
578581
<!-- only call `vm.show()` when the `keyCode` is 13 -->
579582
<input v-on:keyup.13="show">
580583
```
581-
Remembering all the keycodes is really difficult. It supports the full list of keycode aliases
584+
Remembering all the key codes is really difficult. It supports the full list of key codes aliases
582585
1. .enter
583586
2. .tab
584587
3. .delete (captures both “Delete” and “Backspace” keys)
@@ -592,14 +595,15 @@ List of 300 VueJS Interview Questions
592595
Now the above keyup code snippet can be written with aliases as follows,
593596
```javascript
594597
<input v-on:keyup.enter="submit">
595-
(OR)
598+
// (OR)
596599
<!-- with shorthand notation-->
597600
<input @keyup.enter="submit">
598601
```
602+
**The use of keyCode events is deprecated and may not be supported in new browsers.**
599603
21. ### How do you define custom key modifier aliases?
600604
You can define custom key modifier aliases via the global `config.keyCodes`. There are few guidelines for the properties
601-
1. You can't use cameCase, instead you can use kebab-case with double quotation marks
602-
2. You can define multiple values in ann array format
605+
1. You can't use camelCase. Instead you can use kebab-case with double quotation marks
606+
2. You can define multiple values in an array format
603607
```javascript
604608
Vue.config.keyCodes = {
605609
f1: 112,
@@ -613,6 +617,7 @@ List of 300 VueJS Interview Questions
613617
2. .alt
614618
3. .shift
615619
4. .meta
620+
616621
Lets take an example of control modifier with click event,
617622
```javascript
618623
<!-- Ctrl + Click -->
@@ -623,20 +628,25 @@ List of 300 VueJS Interview Questions
623628
1. .left
624629
2. .right
625630
3. .middle
631+
626632
For example, the usage of `.right` modifier as below
627633
```javascript
628-
<button v-if="button === 'right'"
629-
v-on:mousedown.right="increment" v-on:mousedown.left="decrement" />
634+
<button
635+
v-if="button === 'right'"
636+
v-on:mousedown.right="increment"
637+
v-on:mousedown.left="decrement"
638+
/>
630639
```
631-
24. ### How do you implement two way binding?
640+
24. ### How do you implement two-way binding?
632641
You can use the `v-model` directive to create two-way data bindings on form input, textarea, and select elements. Lets take an example of it using input component,
633642
```javascript
634-
<input v-model="message" placeholder="Enter innput here">
643+
<input v-model="message" placeholder="Enter input here">
635644
<p>The message is: {{ message }}</p>
636645
```
637-
Remember, v-model will ignore the initial value, checked or selected attributes found on any form elements. So it always use the Vue instance data as the source of truth.
646+
Remember, v-model will ignore the initial `value`, `checked` or `selected` attributes found on any form elements. So it always use the Vue instance data as the source of truth.
638647
25. ### What are the supported modifiers on model?
639648
There are three modifiers supported for v-model directive.
649+
640650
**1. lazy:** By default, v-model syncs the input with the data after each input event. You can add the lazy modifier to instead sync after change events.
641651
```javascript
642652
<!-- synced after "change" instead of "input" -->
@@ -679,19 +689,19 @@ List of 300 VueJS Interview Questions
679689
template: '<h2>{{ title }}</h2>'
680690
})
681691
```
682-
Once the props registered, you can pass them as custom atrtributes,
692+
Once the props are registered, you can pass them as custom atrtributes.
683693
```javascript
684694
<todo-item title="Learn Vue conceptsnfirst"></todo-item>
685695
```
686696
28. ### When component needs a single root element?
687-
Every component must have a single root element when template has more than one element. In this case, you need to wrap a parent element.
697+
Every component must have a single root element **when template has more than one element**. In this case, you need to wrap the elements with a parent element.
688698
```javascript
689699
<div class="todo-item">
690700
<h2>{{ title }}</h2>
691701
<div v-html="content"></div>
692702
</div>
693703
```
694-
Otherwise there will an error throwing, saying that "wrap those elements with a parent element".
704+
Otherwise there will an error throwing, saying that "Component template should contain exactly one root element...".
695705
29. ### How do you communicate from child to parent using events?
696706
If you want child wants to communicate back up to the parent, then emit an event from child using `$event` object to parent,
697707
```javascript
@@ -723,7 +733,7 @@ List of 300 VueJS Interview Questions
723733
The custom events can also be used to create custom inputs that work with v-model. The <input> inside the component must follow below rules,
724734
1. Bind the value attribute to a value prop
725735
2. On input, emit its own custom input event with the new value.
726-
Lets take a custom-input component as an example,
736+
Let's take a custom-input component as an example,
727737
```javascript
728738
Vue.component('custom-input', {
729739
props: ['value'],

0 commit comments

Comments
 (0)