Wednesday, 21 March 2018
Why ios swift popularity increasing day by day - Online Interview Questions
Why ios swift popularity increasing day by day - Online Interview Questions: IOS Swift:If you are searching for a fantastic way to write software then go for the "SWIFT". Whether it is Desktop, Mobile phones, servers and anything which needs code for run 'Swift' is the fantastic programming language. Swift is an interactive, fast and safe programming language
Sunday, 11 March 2018
Jquery interview questions - Online Interview Questions
Jquery interview questions - Online Interview Questions: Jquery interview questions: jQuery is a lightweight JavaScript library which gives a quick and simple method for HTML DOM traversing and manipulation, its event handling, its client-side animations, and so on. One of the best features of jQuery is that jQuery supports an efficient way to implement AJAX applications.
Sunday, 21 January 2018
Creating and using a service in Angular js
AngularJS services allow you to share code throughout your application, thanks to what is called dependency injection.
AngularJS offers a large number of ready-to-use services (and providers). These are preceded by the $ symbol. Here are some examples:
- $ timeout
- $ http
- $ compiles
If you are new to AngularJS, and before using a method provided by jQuery (randomly), always ask yourself if the framework does not offer a solution. So, to make an Ajax query, prefer to use $ http rather than jQuery.ajax () . In the first case we remain in the domain of AngularJS, in the second case, the view will not be automatically updated on receipt of the data (not instantly anyway).
AngularJS services are:
- Lazily instantiated, that is to say, instantiated only when we need it
- Of singletons, that is to say, they are instantiated only once (not once import)
Here are some examples of use:
- Recover data via Ajax requests (instead of doing it everywhere in the controllers)
- Group "utilities" functions that can be useful everywhere in your application
- Define the parameters of your application (eg development / production mode ...)
Example of creating and using a service
index.html
<! doctype html> <html lang = "en" ng-app = "myApp"> <Head> <meta charset = "UTF-8"> <title> The services </ title> </ Head> <Body> <div ng-controller = "MainCtrl"> <P> {{userData.firstName}} </ p> <P> {{userData.userName}} </ p> <P> {{userData.age}} </ p> </ Div> <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"> </ script> <script src = "app.js"> </ script> </ Body> </ Html>
app.js
var app = angular.module ("myApp", []); / * Main controller ================================================== * / app.controller ("MainCtrl", ["$ scope", "userService", function ($ scope, userService) { $ scope.userData = userService.getUserData (); } ]); / * A first service ================================================== * / app.service ("userService", ["utilsService", "$ timeout", function (utilsService, $ timeout) { // Private variable var userData = { firstName: "natasha", userName: "nat31", age: 25 }; // Getter for the userData variable this.getUserData = function () { // This method uses another service userData.firstName = utilsService.capitalize (userData.firstName); return userData; }; // 5 seconds after loading the page, the value of a property changes in the service. // The view is updated automatically $ timeout (function () { userData.userName = "NATNAT"; }, 5000); } ]); / * A second service ================================================== * / app.service ("utilsService", [ function () { this.capitalize = function (str) { // Credit: http://stackoverflow.com/a/1026087/962893 return str.charAt (0) .toUpperCase () + str.slice (1); }; } ]);
Explanation of the code
The view is content to display the contents of the userData variable of the controller, nothing very complicated:
<div ng-controller = "MainCtrl"> <P> {{userData.firstName}} </ p> <P> {{userData.userName}} </ p> <P> {{userData.age}} </ p> </ Div>
The special feature of this application is that the controller uses a service ( userService ) to retrieve the data:
app.controller ("MainCtrl", ["$ scope", "userService", function ($ scope, userService) { $ scope.userData = userService.getUserData (); } ]);
Note that it would have been possible to give the view direct access to userService, but it would not have been very elegant
:
$ scope.userService = userService;
The declaration of a service is similar to that of a controller. Like a controller, it can take as parameter other services, it is what is called the injection of dependencies . However, you will notice that there is no $ scope parameter , because a service is not directly related to the view.
app.service ("userService", ["utilsService", "$ timeout", function (utilsService, $ timeout) { } ]);
The data is here hard, but we could recover them via an Ajax request thanks to the $ http service :
// Private variable var userData = { firstName: "natasha", userName: "nat31", age: 25 };
Since the function has been declared with this , it is public, so it is accessible from other controllers, services ... as long as the service is injected .
Note also that this service uses another service to capitalize the first letter of the firstName :
// Getter for the userData variable this.getUserData = function () { // This method uses another service userData.firstName = utilsService.capitalize (userData.firstName); return userData; };
Finally, 5 seconds after loading the page, the value of a property changes in the service, but since it is in the AngularJS domain , the view is updated automatically. The change would not have been instantaneous if we had used setTimeout (Javascript):
$ timeout (function () { userData.userName = 'NATNAT'; }, 5000);
Note that $ timeout is also a service
Also Read About
Friday, 19 January 2018
Angular 2 Interview questions
Below are the list of Top 20 Angular2 interview questions and answers.
- What is angular2?
- List some advantages of Angular2 over Angular1?
- What are the new features of Angular2?
- How do you define the transition between two states in Angular?
- How to declare a component in Angular2?
- What is the difference between observable and promises?
- List the differences between Angular2 components vs. directives?
- What is ECMAScript?
- What is Traceur Compiler?
- List the modern browsers supported by Angular2?
- When to use Ngoninit and constructor in angular2?
- How to cache an observable data?
- List out the differences between ActivatedRoute and RouterState, with reference to angular2.
- What would you have in a shared module in Angular2?
- What do you mean by a structural directive in Angular2?
- What do you understand by a template variable? How is it used?
- Explain the concept of lazy loading in Angular2.
- What is the difference between constructor and ngOnlnit in Angular js?
- What is the meaning of component life cycle in Angular2?
- What is the use of ngForTrackBy directive?
For answers please visit https://www.onlineinterviewquestions.com/angular2-interview-questions/
Benefits of using CDN
Content Delivery Networks(CDN) are mainly used to hold static resources like images, videos, CSS or javascript files. You can find all the common javascript libraries like Jquery or frameworks like backbone are hosted for free on servers provided by big web organizations like Google, Microsoft, Yahoo etc.
Commercial CDN's for private use are also available on Amazon, Microsoft Windows Azure & MaxCDN. A reference through CDN is usually recommended as it enhances the performance of your website. Below are some benefits of using a CDN over other methods of referencing.
Following are some Benefits of using CDN.
1. Fast download of your static resources :
Say yours is an application with users from all over the world, your servers are hosted by India but the people accessing your website reside in Europe. If javascript files for your angular framework are hosted with your servers in India, your website is obviously going to take some time to load as it needs to download all the javascript files and being at a distance it is going to hinder the speed. If you have referenced your angular using CDN, the website will load faster as the CDN networks will try to provide the required javascript files from the local servers thus increasing the performance of your application.
2. Common javascript files are pre-cached :
Libraries like jQuery are used in almost all applications. There’s a high chance that someone visiting your web pages has already been to a website which is using the Google CDN. Hence, your browser will not download such libraries as it must have already downloaded it, amplifying your application's performance.
3. Different Domain Names boosts performance :
Web Browsers limit the number of downloads from a single domain from four to six active connections at a time. So if you have multiple javascript files to be downloaded hosted on your web server i.e single domain, it will definitely affect your performance as slow downloads will result in slow web page loading. CDN files are hosted under different domain names.Thus enabling the download of essential javascript files fast.
4. Hosting Infrastructure offered by tech giants :
You may have the best hosting servers available at your disposal but they certainly cannot as good as Google's, Microsoft's or Yahoo's servers. Or the availability offered by these tech giants.
Thanks
Typescript interview questions and answers
Sharing Top 20 Typescript interview questions and answers for freshers
- What is Typescript? How is it different from javascript?
- List some features of Typescript?
- List some benefits of using Typescript>
- Who developed Typescript and what is the current stable version of Typescript?
- Tell the minimum requirements for installing Typescript. Also mention the steps involved in it.
- List the built-in types in Typescript.
- What are variables in Typescript? How to create a variable in Typescript?
Sunday, 14 January 2018
Latest Interview questions on D3.js
D3.js is the successor of Protovis and provides great control over the final visual result.It uses SVG, HTML5, and CSS for creating data visualizations.
Below is list of some latest interview questions on D3.js.
- What is D3.js?
- What does D3 stand for?
- Who developed D3.js?
- Why use to D3.js?
- How D3.js identify on which elements to operate?
- Explain selections in D3.js?
- Explain, what is the use of “Enter” and “Exit” selection in D3.js?
- List Type of sliders are available in D3.js?
- Explain transition in D3.js?
- List the command to interpolate two objects in D3.js?
For More Questions on D3 js and Answers please visit https://www.devquora.com/articles/d3-js-interview-questions
Originally Posted On Devquora in D3.js Wall(https://www.devquora.com/d3js)
Subscribe to:
Posts (Atom)