Skip to content

Commit cbdd0ab

Browse files
committed
fix some markdown syntax and mistypings
1 parent 293fcf1 commit cbdd0ab

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

README.md

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,8 +1160,8 @@ List of 300 VueJS Interview Questions
11601160
</style>
11611161
```
11621162
48. ### Is Single File Components violating separation of concerns?
1163-
As per the latest modern UI development, separation of concerns is not equal to separation of file types. So it is preferred to divide codebase layers into loosely-coupled components and compose them instead of dividing the codebase into three huge layers that interweave with one another. This way it makes Single File Components more cohesive and maintainable by combining template, logic and styles together inside a component.
1164-
You can also still maintain javascript and CSS files as separate with hot-reloading and pre-compilation features. For example,
1163+
As for the latest modern UI development, separation of concerns is not equal to separation of file types. So it is preferred to divide codebase layers into loosely-coupled components and compose them instead of dividing the codebase into three huge layers that interweave with one another. This way makes Single File Components more cohesive and maintainable by combining template, logic and styles together inside a component.
1164+
You can also still maintain javascript and CSS files separately with hot-reloading and pre-compilation features. For example,
11651165
```
11661166
<template>
11671167
<div>This section will be pre-compiled and hot reloaded</div>
@@ -1180,7 +1180,7 @@ List of 300 VueJS Interview Questions
11801180
1. mustache interpolations
11811181
2. v-bind expressions
11821182
1183-
For example, Let's define local filter named camelcase in a component’s options
1183+
For example, Let's define a local filter named capitalize in a component’s options
11841184
```javascript
11851185
filters: {
11861186
capitalize: function (value) {
@@ -1193,7 +1193,7 @@ List of 300 VueJS Interview Questions
11931193
Now you can use the filter in either mustache interpolation or v-bind expression,
11941194
```javascript
11951195
<!-- in mustaches -->
1196-
{{ username | camelcase }}
1196+
{{ username | capitalize }}
11971197

11981198
<!-- in v-bind -->
11991199
<div v-bind:id="username | capitalize"></div>
@@ -1227,12 +1227,12 @@ List of 300 VueJS Interview Questions
12271227
52. ### How do you chain filters?
12281228
You can chain filters one after the other to perform multiple manipulations on the expression. The generic structure of filter chain would be as below,
12291229
```javascript
1230-
{{ message | filterA | filterB | filterB ...}}
1230+
{{ message | filterA | filterB | filterB ... }}
12311231
```
12321232
In the above chain stack, you can observe that message expression applied with three filters, each separated by a pipe(|) symbol. The first filter(filterA) takes the expression as a single argument and the result of the expression becomes an argument for second filter(filterB) and the chain continue for remaining filters.
12331233
For example, if you want to transform date expression with a full date format and uppercase then you can apply dateFormat and uppercase filters as below,
1234-
```javascirpt
1235-
{{ birthday | dateFormat | uppercase}}
1234+
```javascript
1235+
{{ birthday | dateFormat | uppercase }}
12361236
```
12371237

12381238
53. ### Is it possible to pass parameters for filters?
@@ -1247,14 +1247,14 @@ List of 300 VueJS Interview Questions
12471247
```
12481248
54. ### What are plugins and their various services?
12491249
1250-
Plugins provides global-level functionality to Vue application. The plugins provides various services,
1250+
Plugins provides global-level functionality to Vue application. The plugins provide various services,
12511251
1. Add some global methods or properties. For example, vue-custom-element
12521252
2. Add one or more global assets (directives, filters and transitions). For example, vue-touch
12531253
3. Add some component options by global mixin. For example, vue-router
12541254
4. Add some Vue instance methods by attaching them to Vue.prototype.
12551255
5. A library that provides an API of its own, while at the same time injecting some combination of the above. For example, vue-router
12561256
55. ### How to create a plugin?
1257-
The Plugin is created by exposing an install method which takes Vue constructor as a first argument along with options. The structure of VueJS plugin with possible functionality would be as follows,
1257+
The Plugin is created by exposing an `install` method which takes Vue constructor as a first argument along with options. The structure of VueJS plugin with possible functionality would be as follows,
12581258
```javascript
12591259
MyPlugin.install = function (Vue, options) {
12601260
// 1. add global method or property
@@ -1295,7 +1295,7 @@ List of 300 VueJS Interview Questions
12951295
})
12961296
```
12971297
57. ### What are mixins?
1298-
Mixin gives us a way to distribute reusable functionality in Vue components. These reusable functions are merged with existing functions. A mixin object can contain any component options. Let us take an example of mixin with created lifecycle which can be shared across components,
1298+
Mixin gives us a way to distribute reusable functionalities in Vue components. These reusable functions are merged with existing functions. A mixin object can contain any component options. Let us take an example of mixin with `created` lifecycle which can be shared across components,
12991299
```javascript
13001300
const myMixin = {
13011301
created(){
@@ -1307,7 +1307,7 @@ List of 300 VueJS Interview Questions
13071307
mixins: [myMixin]
13081308
})
13091309
```
1310-
**Note:**Multiple mixins can be specified in the mixin array of the component.
1310+
**Note:** Multiple mixins can be specified in the mixin array of the component.
13111311
58. ### What are global mixins?
13121312
Sometimes there is a need to extend the functionality of Vue or apply an option to all Vue components available in our application. In this case, mixins can be applied globally to affect all components in Vue. These mixins are called as global mixins. Let's take an example of global mixin,
13131313
```javascript
@@ -1323,7 +1323,7 @@ List of 300 VueJS Interview Questions
13231323
```
13241324
In the above global mixin, the mixin options spread across all components with the console running during the instance creation. These are useful during test, and debugging or third party libraries. At the same time, You need to use these global mixins sparsely and carefully, because it affects every single Vue instance created, including third party components.
13251325
59. ### How do you use mixins in CLI?
1326-
Using Vue CLI, mixins can be specified anywhere in the project folder but preferably within `/src/mixins` for ease of access. Once these mixins are created in a `.js` file and exposed with the `export` keyword, they can be imported in any component with the `import` keyword and its file path.
1326+
Using Vue CLI, mixins can be specified anywhere in the project folder but preferably within `/src/mixins` for ease of access. Once these mixins are created in a `.js` file and exposed with the `export` keyword, they can be imported in any component with the `import` keyword and their file paths.
13271327
60. ### What are the merging strategies in mixins?
13281328
When a mixin and the component itself contain overlapping options, the options will be merged based on some strategies.
13291329
1. The data objects undergo a recursive merge, with the component’s data taking priority over mixins in cases of overlapping or conflicts.
@@ -1433,7 +1433,7 @@ List of 300 VueJS Interview Questions
14331433
<input v-focus>
14341434
```
14351435
63. ### How do you register directives locally?
1436-
You can also register directives locally(apart from globally) using directives option with in component as below,
1436+
You can also register directives locally(apart from globally) using directives option in component as below,
14371437
```javascript
14381438
directives: {
14391439
focus: {
@@ -1454,20 +1454,21 @@ List of 300 VueJS Interview Questions
14541454
2. inserted: This hook occurs once the element is inserted into the parent DOM.
14551455
3. update: This hook is called when the element updates, but children haven't been updated yet.
14561456
4. componentUpdated: This hook is called once the component and the children have been updated.
1457-
5. unbind: This hook is called once the directive is removed.
1458-
**Note:** There are several arguments can be passed to the above hooks.
1457+
5. unbind: This hook is called only once when the directive is removed.
1458+
1459+
**Note:** There are several arguments that can be passed to the above hooks.
14591460
65. ### What are the directive Hook Arguments?
1460-
All the hooks have **el, binding, and vnode** as arguments. Along with that, **update and componentUpdated** hooks expose oldVnode, to differentiate between the older value passed and the newer value. Below are the arguments passed to the hooks,
1461-
1. el: The element the directive is bound to and it can be used to directly manipulate the DOM.
1462-
2. binding: An object containing the following properties.
1463-
1. name: The name of the directive, without the v- prefix.
1464-
2. value: The value passed to the directive. For example in v-my-directive="1 + 1", the value would be 2.
1465-
3. oldValue: The previous value, only available in update and componentUpdated. It is available whether or not the value has changed.
1466-
4. expression: The expression of the binding as a string. For example in v-my-directive="1 + 1", the expression would be "1 + 1".
1467-
5. arg: The argument passed to the directive, if any. For example in v-my-directive:foo, the arg would be "foo".
1468-
6. modifiers: An object containing modifiers, if any. For example in v-my-directive.foo.bar, the modifiers object would be { foo: true, bar: true }.
1469-
3. vnode: The virtual node produced by Vue’s compiler.
1470-
4. oldVnode: The previous virtual node, only available in the update and componentUpdated hooks.
1461+
All the hooks have `el`, `binding`, and `vnode` as arguments. Along with that, **update** and **componentUpdated** hooks expose `oldVnode`, to differentiate between the older value passed and the newer value. Below are the arguments passed to the hooks,
1462+
1. `el`: The element the directive is bound to and it can be used to directly manipulate the DOM.
1463+
2. `binding`: An object containing the following properties.
1464+
1. `name`: The name of the directive, without the `v-` prefix.
1465+
2. `value`: The value passed to the directive. For example in `v-my-directive="1 + 1"`, the value would be 2.
1466+
3. `oldValue`: The previous value, only available in update and componentUpdated. It is available whether or not the value has changed.
1467+
4. `expression`: The expression of the binding as a string. For example in `v-my-directive="1 + 1"`, the expression would be "1 + 1".
1468+
5. `arg`: The argument passed to the directive, if any. For example in v-my-directive:foo, the arg would be "foo".
1469+
6. `modifiers`: An object containing modifiers, if any. For example in v-my-directive.foo.bar, the modifiers object would be `{ foo: true, bar: true }`.
1470+
3. `vnode`: The virtual node produced by Vue’s compiler.
1471+
4. `oldVnode`: The previous virtual node, only available in the update and componentUpdated hooks.
14711472
14721473
The arguments can be represented diagrammatically across the hooks as below,
14731474
![custom-directives](images/custom-directives.svg)
@@ -1487,14 +1488,14 @@ List of 300 VueJS Interview Questions
14871488
})
14881489
```
14891490
67. ### What is function shorthand in directive hooks?
1490-
In few cases, you may want the same behavior on **bind and update** hooks irrespective of other hooks. In this situation you can use function shorthand,
1491+
In few cases, you may want the same behavior on `bind` and `update` hooks irrespective of other hooks. In this situation you can use function shorthand,
14911492
```javascript
14921493
Vue.directive('theme-switcher', function (el, binding) {
14931494
el.style.backgroundColor = binding.value
14941495
})
14951496
```
14961497
68. ### What is the benefit of render functions over templates?
1497-
In VueJS, the templates are very powerful and recommended to build HTML part of your application. However, some of the special cases like dynamic component creation based on input or slot value can be achieved through render functions. Also, these functions gives the full programmatic power of javascript eco system.
1498+
In VueJS, the templates are very powerful and recommended to build HTML as part of your application. However, some of the special cases like dynamic component creation based on input or slot value can be achieved through render functions. Also, these functions gives the full programmatic power of javascript eco system.
14981499
69. ### What is a render function?
14991500
Render function is a normal function which receives a `createElement` method as it’s first argument used to create virtual nodes. Internally Vue.js' templates actually compile down to render functions at build time. Hence templates are just syntactic sugar of render functions. Let's take an example of simple Div markup and corresponding render function,
15001501
The HTML markup can be written in template tag as below,
@@ -1508,11 +1509,13 @@ List of 300 VueJS Interview Questions
15081509
and the compiled down or explicit render function would appear as below,
15091510
```javascript
15101511
render: function (createElement) {
1511-
return createElement('div',
1512-
{ 'class': {
1513-
'is-rounded': this.isRounded
1514-
}
1515-
},[ createElement('p', 'Welcome to Vue render functions')])
1512+
return createElement('div', {
1513+
'class': {
1514+
'is-rounded': this.isRounded
1515+
}
1516+
}, [
1517+
createElement('p', 'Welcome to Vue render functions')
1518+
]);
15161519
},
15171520
```
15181521
**Note:** The react components are built with render functions in JSX.
@@ -1521,12 +1524,14 @@ List of 300 VueJS Interview Questions
15211524
```javascript
15221525
// @returns {VNode}
15231526
createElement(
1524-
// An HTML tag name, component options, or async function resolving to one of these. Required.
1527+
// An HTML tag name, component options, or async function resolving to one of these.
15251528
// Type is {String | Object | Function}
1529+
// Required.
15261530
'div',
15271531
1528-
// A data object corresponding to the attributes you would use in a template. Optional.
1532+
// A data object corresponding to the attributes you would use in a template.
15291533
//Type is {Object}
1534+
// Optional.
15301535
{
15311536
// Normal HTML attributes
15321537
attrs: {
@@ -1557,8 +1562,9 @@ List of 300 VueJS Interview Questions
15571562
....
15581563
},
15591564
1560-
// Children VNodes, built using `createElement()`, or using strings to get 'text VNodes'. Optional.
1565+
// Children VNodes, built using `createElement()`, or using strings to get 'text VNodes'.
15611566
// Type is {String | Array}
1567+
// Optional.
15621568
[
15631569
'Learn about createElement arguments.',
15641570
createElement('h1', 'Headline as a child virtual node'),
@@ -1570,6 +1576,7 @@ List of 300 VueJS Interview Questions
15701576
]
15711577
)
15721578
```
1579+
see details of the date object in official [doc](https://vuejs.org/v2/guide/render-function.html#The-Data-Object-In-Depth).
15731580
71. ### How can you write duplicate virtual nodes in a component?
15741581
All virtual nodes(VNodes) in the component tree must be unique.i.e, You can't write duplicated nodes in a straightforward way. If you want to duplicate the same element/component many times then you should use factory function.
15751582
The below render function is invalid where you are trying to duplicate h1 element 3 times,

0 commit comments

Comments
 (0)