This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which Are The Most Used Gruntjs Plugins? |
|
Answer» The lists of Plugins are:
The lists of Plugins are: |
|
| 2. |
What Are The Advantages? |
|
Answer» Some of the Advantages of USING Gruntjs: 1.Access too many PREDEFINED plugins that can be used to work with JavaScript TASKS and on static content. 2.All task runners have the following properties: consistency, effectiveness, efficiency, repeatability, etc. 3.Allows USERS to customize tasks using predefined plugins 4.Prefers the configuration approach to coding 5.Allows users to add their own plugins and PUBLISH them to npm. Some of the Advantages of using Gruntjs: 1.Access too many predefined plugins that can be used to work with JavaScript tasks and on static content. 2.All task runners have the following properties: consistency, effectiveness, efficiency, repeatability, etc. 3.Allows users to customize tasks using predefined plugins 4.Prefers the configuration approach to coding 5.Allows users to add their own plugins and publish them to npm. |
|
| 3. |
Is It Possible To Run The Multiple Tasks Together In Grunt? |
|
Answer» Yes, this can be DONE. This APPROACH helps DEVELOPER's LOTS of time. Yes, this can be done. This approach helps developer's lots of time. |
|
| 4. |
Is It Possible To Check Js Errors With The Help Of Grunt? |
|
Answer» Yes, it can simply be done. |
|
| 5. |
Why To Use Grunt Js? |
|
Answer» Grunt has become very POPULAR and has tons of plugins to choose from. These plugins are great ASSETS for any app to automate various THINGS with MINIMUM efforts. Grunt has become very popular and has tons of plugins to choose from. These plugins are great assets for any app to automate various things with minimum efforts. |
|
| 6. |
How To Install And Use Grunt.js? |
|
Answer» The multiple Steps INVOLVES to install and use Grunt.js:
The multiple Steps involves to install and use Grunt.js: |
|
| 7. |
Why Use A Task Runner? |
|
Answer» A task runner can do most of your WORKS with zero EFFORT. All task runners have the following PROPERTIES:
A task runner can do most of your works with zero effort. All task runners have the following properties: |
|
| 8. |
What Is Grunt Js? |
Answer»
|
|
| 9. |
Which Are The Most Used Grunt Plugins? |
|
Answer» Though there are tons of PLUGINS which you can use, but below are the most used.
Below is a sample gruntfile.JS for your reference.
Though there are tons of plugins which you can use, but below are the most used. Below is a sample gruntfile.js for your reference. |
|
| 10. |
How To Get A Stack Trace When An Error Occurs? |
|
Answer» USE the --STACK OPTION to see stack TRACES. Such as GRUNT task –stack. Use the --stack option to see stack traces. Such as grunt task –stack. |
|
| 11. |
How To Run Multiple Tasks Together In Grunt? |
|
Answer» Every grunt module MAY have defined a task. But running them individually can make things difficult for developers. What is one wants to run grunt uglify and grunt jshint together Using grunt.registerTask(taskName, [description, ] taskList) we can group all the tasks under one roof. Task NAME can be anything of your choice, description is optional and task list is array of module tasks which you wish to execute. For example, grunt.registerTask('development', ['jshint:development', 'concat:development', 'uglify:development']); Above code creates a task named “development” and is asked to execute development target of “jshint”, “concat” and “uglify” packages. Similarly, you can register another task for PRODUCTION VERSION. grunt.registerTask('production', ['jshint:production', 'concat:production', 'uglify:production']); Remember, you always need to define a default task. grunt.registerTask('default', ['jshint', 'uglify', 'concat']); Now, when you enter grunt on command prompt, it will execute the default task. Every grunt module may have defined a task. But running them individually can make things difficult for developers. What is one wants to run grunt uglify and grunt jshint together Using grunt.registerTask(taskName, [description, ] taskList) we can group all the tasks under one roof. Task name can be anything of your choice, description is optional and task list is array of module tasks which you wish to execute. For example, grunt.registerTask('development', ['jshint:development', 'concat:development', 'uglify:development']); Above code creates a task named “development” and is asked to execute development target of “jshint”, “concat” and “uglify” packages. Similarly, you can register another task for production version. grunt.registerTask('production', ['jshint:production', 'concat:production', 'uglify:production']); Remember, you always need to define a default task. grunt.registerTask('default', ['jshint', 'uglify', 'concat']); Now, when you enter grunt on command prompt, it will execute the default task. |
|
| 12. |
How Do We Load Grunt Plugins In Gruntfile.js? |
|
Answer» GRUNT.loadNpmTasks() is used for LOADING grunt plugins. Before loading, please ensure that these plugins are ALREADY installed VIA NPM. grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks() is used for loading grunt plugins. Before loading, please ensure that these plugins are already installed via npm. grunt.loadNpmTasks('grunt-contrib-uglify'); |
|
| 13. |
How Do You Execute Grunt Task? |
|
Answer» You can execute the grunt TASK from COMMAND line. Remember, we have grunt command line INTERFACE. To execute contact MODULE with grunt for all the tasks. grunt CONCAT To execute task with particular target grunt concat:development You can execute the grunt task from command line. Remember, we have grunt command line interface. To execute contact module with grunt for all the tasks. grunt concat To execute task with particular target grunt concat:development |
|
| 14. |
What Is A Task In Grunt? |
|
Answer» Tasks are grunt’s bread and butter. Every time Grunt is run, you specify one or more tasks to run, which tells Grunt what you’d like it to do. See below code.
Here, there are 2 tasks DEFINED concat and uglify. And for each task, we defined TARGETS. For concat, there are 2 targets “development” and “production” and only “development” for uglify. Creating target allows us to define separate settings for different objectives. Here, we can have different option for development and production version. It’s not COMPULSORY to define a target. Target’s can also have their own option parameters which will OVERRIDE the settings of options defined for the task. Tasks are grunt’s bread and butter. Every time Grunt is run, you specify one or more tasks to run, which tells Grunt what you’d like it to do. See below code. Here, there are 2 tasks defined concat and uglify. And for each task, we defined targets. For concat, there are 2 targets “development” and “production” and only “development” for uglify. Creating target allows us to define separate settings for different objectives. Here, we can have different option for development and production version. It’s not compulsory to define a target. Target’s can also have their own option parameters which will override the settings of options defined for the task. |
|
| 15. |
Can You Override Default Settings Of A Plugin? If Yes, Then How? |
|
Answer» Yes, we can override. Inside a TASK configuration, an options property MAY be SPECIFIED to override built-in defaults. In ADDITION, each target may have an options property which is specific to that target.
Yes, we can override. Inside a task configuration, an options property may be specified to override built-in defaults. In addition, each target may have an options property which is specific to that target. |
|
| 16. |
Where Do You Define Configuration Of Grunt Plugin? |
|
Answer» GRUNT plugin configuration needs to be DEFINED within grunt.initConfig method. See below sample CODE.
Above code configures concat and uglify tasks. Grunt plugin configuration needs to be defined within grunt.initConfig method. See below sample code. Above code configures concat and uglify tasks. |
|
| 17. |
How Does Gruntfile.js Uses Package.json? |
|
Answer» Task configuration is specified in your Gruntfile via the grunt.initConfig method. Inside of grunt.initConfig(), we READ the information from package.json and SAVED it to a pkg PROPERTY. With this, we can use the attributes from our package.json file. We can call the name of our PROJECT using pkg.name and the version with pkg.version.
Task configuration is specified in your Gruntfile via the grunt.initConfig method. Inside of grunt.initConfig(), we read the information from package.json and saved it to a pkg property. With this, we can use the attributes from our package.json file. We can call the name of our project using pkg.name and the version with pkg.version. |
|
| 18. |
What Is Grunt-cli? |
|
Answer» GRUNT cli is COMMAND line interface to run grunt commands. In other words, it’s a tool to access Grunt from command line anywhere in the system. To INSTALL, grunt –cli execute following command npm install -g grunt-cli This will put the grunt command in your system path, allowing it to be run from any directory. Please note, that installing grunt-cli, doesn’t install grunt on your system. -g MEANS global which means it adds to PATH variables of the system so that you can run grunt from anywhere (without going to specific FOLDER on command prompt). The reason for having two components is to ensure that we can run different grunt versions side-by-side (i.e. legacy versions in older projects). Hence it is recommended to install grunt-cli globally while grunt should be installed on a per-project basis. Grunt cli is command line interface to run grunt commands. In other words, it’s a tool to access Grunt from command line anywhere in the system. To install, grunt –cli execute following command npm install -g grunt-cli This will put the grunt command in your system path, allowing it to be run from any directory. Please note, that installing grunt-cli, doesn’t install grunt on your system. -g means global which means it adds to PATH variables of the system so that you can run grunt from anywhere (without going to specific folder on command prompt). The reason for having two components is to ensure that we can run different grunt versions side-by-side (i.e. legacy versions in older projects). Hence it is recommended to install grunt-cli globally while grunt should be installed on a per-project basis. |
|
| 19. |
How Do You Uninstall Grunt? |
|
Answer» Run following command to UNINSTALL grunt.
And if you wish to remove it from package.json, then USE --save-dev OPTION.
Run following command to uninstall grunt. And if you wish to remove it from package.json, then use --save-dev option. |
|
| 20. |
How Do You Install A Grunt Plugin? |
|
Answer» The syntax REMAINS name but the only thing which changes is module/plugin name. For example, to install UGLIFY plugin:
By default, it always installs the latest version available. But if you wish to install SPECIFIC version then same you can include in the command.
The syntax remains name but the only thing which changes is module/plugin name. For example, to install uglify plugin: By default, it always installs the latest version available. But if you wish to install specific version then same you can include in the command. |
|
| 21. |
What Are Grunt Modules/plugins? |
|
Answer» Grunt modules are distributed through Node’s NPM DIRECTORY. NORMALLY, they are prefixed with grunt- and OFFICIAL grunt plugins are prefixed with grunt-contrib. Example: grunt-contrib-uglify. You can get list of all grunt plugins here. Grunt modules are distributed through Node’s NPM directory. Normally, they are prefixed with grunt- and official grunt plugins are prefixed with grunt-contrib. Example: grunt-contrib-uglify. You can get list of all grunt plugins here. |
|
| 22. |
What Does ~ (tilde) Sign Means In Package.json? |
|
Answer» In the simplest TERMS, the tilde matches the most recent minor version (the middle NUMBER). ~1.2.3 will match all 1.2.x versions but will MISS 1.3.0. The caret, on the other HAND, is more relaxed. It will update you to the most recent major version (the first number). ^1.2.3 will match any 1.x.x release INCLUDING 1.3.0, but will hold off on 2.0.0. You can also define the exact version number that you wish to use like “1.3.5” or to always use latest version, simply use latest or *. In the simplest terms, the tilde matches the most recent minor version (the middle number). ~1.2.3 will match all 1.2.x versions but will miss 1.3.0. The caret, on the other hand, is more relaxed. It will update you to the most recent major version (the first number). ^1.2.3 will match any 1.x.x release including 1.3.0, but will hold off on 2.0.0. You can also define the exact version number that you wish to use like “1.3.5” or to always use latest version, simply use latest or *. |
|
| 23. |
What Is The Difference Between --save And --save-dev? |
|
Answer» Before will look at the difference, it is IMPORTANT to understand the difference between dependencies and devDependencies. devDependencies are for the development-related scripts, e.g. unit testing, packaging scripts, DOCUMENTATION generation, etc. where dependencies are required for production USE, and assumed required for dev as well. As for example, you can include some plugin which you require during development like (for debugging or unit testing) but you don’t need them on production. So --save adds packages under dependencies and --save-dev adds under devdependencies SECTION.
Before will look at the difference, it is important to understand the difference between dependencies and devDependencies. devDependencies are for the development-related scripts, e.g. unit testing, packaging scripts, documentation generation, etc. where dependencies are required for production use, and assumed required for dev as well. As for example, you can include some plugin which you require during development like (for debugging or unit testing) but you don’t need them on production. So --save adds packages under dependencies and --save-dev adds under devdependencies section. |
|
| 24. |
What Is --save-dev Option While Installing The Grunt? |
|
Answer» As mentioned in previous ANSWER that “package.json” file holds the METADATA for grunt plugins. So when grunt is installed USING --save-dev option, the metadata is added to package.json. So you don’t have to add it manually. And this is how your package.json will look LIKE,
As mentioned in previous answer that “package.json” file holds the metadata for grunt plugins. So when grunt is installed using --save-dev option, the metadata is added to package.json. So you don’t have to add it manually. And this is how your package.json will look like, |
|
| 25. |
How Do You Setup/configure Grunt? |
|
Answer» Once INSTALLED, you need to add 2 files to setup Grunt. 1. package.json: This file is used by NPM to store metadata for projects published as npm modules. So basically, there will be list of all Grunt plugins, along with grunt which your project is using. 2. Gruntfile: This file is NAMED Gruntfile.js and is used to CONFIGURE or define tasks and load Grunt plugins. Once installed, you need to add 2 files to setup Grunt. 1. package.json: This file is used by npm to store metadata for projects published as npm modules. So basically, there will be list of all Grunt plugins, along with grunt which your project is using. 2. Gruntfile: This file is named Gruntfile.js and is used to configure or define tasks and load Grunt plugins. |
|
| 26. |
How Do You Install Grunt? |
|
Answer» GRUNT and Grunt plugins are installed and managed via npm, the Node.js PACKAGE manager. To install grunt, first ENSURE the npm is installed properly. And then run following COMMAND.
PLEASE note, --save-dev is optional. Grunt and Grunt plugins are installed and managed via npm, the Node.js package manager. To install grunt, first ensure the npm is installed properly. And then run following command. Please note, --save-dev is optional. |
|
| 27. |
Why To Use Grunt? |
|
Answer» GRUNT has BECOME very popular and has tons of plugins to choose from. These plugins are great assets for any APP to AUTOMATE various THINGS with minimum efforts. Grunt has become very popular and has tons of plugins to choose from. These plugins are great assets for any app to automate various things with minimum efforts. |
|
| 28. |
What Is Grunt? |
|
Answer» Grunt is a JAVASCRIPT TASK runner, which can automate tasks like minification, compilation, UNIT testing, CHECKING js errors. Once CONFIGURED, one doesn’t have to worry about these tasks. Grunt is a JavaScript task runner, which can automate tasks like minification, compilation, unit testing, checking js errors. Once configured, one doesn’t have to worry about these tasks. |
|