Showing posts with label AngularJS. Show all posts
Showing posts with label AngularJS. Show all posts

23 Typescript interview questions and answers for beginners

Welcome to Typescript interview questions (pdf) and answers for beginners, Here are some tricky typescript interview question and answers collection which is asked in the interview. May it will help you to crack your typescript interview.

Typescript interview questions and answers for beginners
Typescript interview questions and answers

1. What is namespace in Typescript? Write the declaration of the namespace.

I think Everyone familiar with the namespace of other languages, here also in TypeScript a namespace is just a collection of classes by which we can logically categories. If we want to access any class from outside of the namespace then we need to export keyword.

namespace People
      export class Boss
      export class Employee
      export interface Iofficework


2. What is Typescript?

TypeScript is known as Object-oriented programming language developed and maintained by Microsoft. Which is provide you to optional parameters, classes, and interfaces.TypeScript is nothing but JavaScript and some additional features i.e. ES6 features. Whenever we compile the TypeScript code it first converts in JavaScript then it runs and we get output.

3.Difference between typescript and javascript?

1. Typescript is a superset of JavaScript whereas JavaScript is a scripting language.
2. Typescript has an interface concept but JavaScript havan't.
3.TypeScript doesn't run in the browser where JavaScript runs.
4.TypeScript has classes whereas JavaScript has functions.
5. Typescript support module whereas JavaScript doesn't support modules.
6. In typescript Number, a string is the interfaces whereas In, JavaScript Number, string are the Object.

4. What are the key features of typescript?

TypeScript supports different browsers or node.js versions and optimizes the resulting JavaScript. It is much easier to write clean, consistent code across a project and development team.

5.When to use a super keyword in typescript.

In typescript, Super keyword is used to reference base class properties and the base class constructor.

6.How to access static methods in TypeScript

7. What Are Classes In Typescript?

The concept of classes is very similar to .NET/Java. A Class can have constructor, member variables, properties, and methods. TypeScript also allows access to modifiers “private” and “public” for member variables and functions.

8. Tell me the command for installing typescript.

npm install -g typescript

9. What Are The Benefits Of Typescript?

TypeScript has the following benefits:

2Impose coding guidelines
3.Offers type checking
4. It helps in code structuring
5.Compile time error checking
6. Use class-based object-oriented programming

10. What is the typescript extension and how you compile?

Typescript extension is '.ts'. It is just a javascript file, when we compile typescript file, just after compilation it convert into '.js' file.

Step to compile a typescript program
1. tsc 'your typeScript File Name'
For example, to compile “program.ts”:
tsc program.ts

After compilation, you will get

11. How to declare a variable in Typescript?

var name:string="sham"
var phone:string="123456"

12. How do you declare an undefined variable?

var name:string;

var phone:int;

13. How to declare and initialize an array in Typescript?

var names:string[];       -- Declaration

names=["a","b","c","d"]   -- Initialization

14. How to achieve inheritance in Typescript?

15. How to make a module in Typescript?

16. What is the role of constructor in Typescript?

A constructor is responsible for initializing the variable of the class.

17. How to initialize the static variables?

class office
   static phoneNo:number=101;
   console.log(office.phoneNo) ;

18. What is the difference between var and let in Typescript?

1.var declaration done at function scoped and let declaration done at block scoped.
2.var allow you to re-declare the same variable in the same scope. whereas let will not

19.How to define a global variable in a typescript module.

20.How to export a variable.

export var demo = [1,2,3];

21. What is the role of var keyword in typescript?

var is key it helps us to create an object of a class.

22. How to Convert string to number in TypeScript?

   //convert string to number
   this.empcode = Number(name);

23. Can we debug Typescript file?

Yes, With the help of .js source map file.

24. What are the classes in TypeScript?

Typescript class is very similar to other languages like (.Net, Java). As we know that class can have constructor, member, variable and methods.

25. What are the benefits of Typescript?

1. ES7 and ES6 Features support.
2. User-friendly for Java and .Net programmer.
3. Intellisense.
4. Object Oriented programming support.

TAG: Typescript interview questions and answers for beginners, Typescript interview question and answers, beginner typescript question and answer

Read More

Javascript interview questions and answers for freshers and experienced

                                 What is JavaScript?

JavaScript is a loosely-type client side scripting language that execute in the user's browser.JavaScript interact with html elements in order to make interactive web user interface.JavaScript can be used in various activities like data validation,display popup message.

Javascript interview questions and answers
Javascript interview questions and answers

Q.1 Can you access Cookie using javascript?

Q.2 Can you assign a anonymous function to a variable?
 Yes,But Anonymous JavaScript function assigned to a variable can be called at a later time.

Q.3 Define unescape() and escape() functions?
 See this:

Q.4 Is a javascript script faster than an ASP script?
 Yes, javascript is faster than ASP script.Because javascript is develop for client side whereas ASP  Script is server side.

Q.5 Can you pass a anonymous function as an argument to another function?
 See this:

                                     Javascript tricky interview questions

Q.6 Does JavaScript support automatic type conversion?
 Yes! Javascript support automatic type conversion.

Q.7 Explain the difference between “==” and “===”?
 See this:

Q.8 How to read and write a file using javascript?
 By using java script functions – fopen(),fread() and fwrite().

Q.9 How to delete a Cookie using JavaScript?
 See this:

Q.10 How to print a web page using javascript?

                                       Javascript tricky interview questions

Q.11 How to read elements of an array in JavaScript?
 var fruit = ["Mango", "Apple", "Banana"];
 var arry_name=["Item1","Item2","Item3"]

Q.12 How to redirect a url using JavaScript?
 window.location = "";

Q.13 What are JavaScript Data Types?
 See this:

Q.14 What is the use of blur function?
  If we use the blur method for the active element, then it loses the active state.

Q.15 What is the purpose of ‘this’ operator in JavaScript?
 When a function is called as a property on a parent object, this refers to the parent object inside that function.

                                         Javascript tricky interview questions

Q.16 Explain what is pop()method in JavaScript?
 See this:

Q.17 How generic objects can be created?
 See this:

Q.18 What are Screen objects?
 See this:

Q.19 What are the different types of errors in JavaScript?
 See this:

Q.20 What are the advantages of using JavaScript?

1.Easy to learn.
2.It execute on client's browser,so eliminate server side processing.
3.It execute on any OS.
4.JavaScript can be used with any type of web page e.g. PHP,ASP.NET,Perl etc.
5.Performance of web page increases due to client side execution.
Read More

Angularjs tricky interview questions

1.What is AngularJS ?

AngularJS is a javascript open source framework used for making extensible web applications and dynamic web pages.It allows you to use HTML as your template language and runs on plain javascript and HTML.

Angularjs tricky interview questions

2.Define scope in AngularJS.

Scope is an object that refers to the application model. It acts as glue between controller and view. Scopes are hierarchical in nature and follow the DOM (Document Object Model) structure of your angular app.

AngularJS has two scope objects: $rootScope and $scope.

A $scope is a JavaScript object which is used for communication between controller and view. Basically, $scope binds a view (DOM element) to the view model and functions defined in a controller.

The $rootScope is the top-most scope. An app can have only one $rootScope which will be shared among all the components of an app. Hence it acts like a global variable. All other $scopes are children of the $rootScope.

3.Is AngularJS compatible with all browsers? 


4.What are directives? 

Directive is used to provide extra functionality on the HTML element. For instance, the ng-click directive gives an element the ability to listen for the click event and run an Angular expression when it receives the event.Directives are what makes the Angular framework so powerful, and, as we’ve seen, we can also create them.
A directive is defined using the .directive() method, one of the many methods available on our applications Angular module.

5.What are the types of Directive?

Element directives
Attribute directives
CSS class directives
Comment directives

6.Explain what are the key features of AngularJS?

Key features of AngularJS are

Data Binding

7.What is services in AngularJS?

In angularjs service is the function which is used to handle the server communication over the browser with help of XMLHttpRequest object and $http.

8.What is the Template in AngularJS?

The template is the HTML portion of the angular app. It is exactly like a static HTML page, except that templates contain additional syntax which allows data to be injected in it in order to provide a customized user experience.

9.What are basic steps to set up an Angular app?

Create an angular.module
Assign a controller to the module
Link your module to HTML with ng-app
Link the controller to HTML with ng-controller directive.

10.Is AngularJS a library or framework?

AngularJS is not a library but open source client side MVC (Model View Controller) framework for creating dynamic web applications. It is lightweight and can use jQuery library if it's present in your application when the app is being bootstrapped. If jQuery is not present in your script path, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.

11.What is Single Page Application (SPA)? 

SPA is the concept whereby pages are loaded from the server not by doing post backs, rather by creating a single shell page or master page and loading the web pages into the master page.

12.Who created Angular JS?

Angular JS was developed by Misko Hevery and Adam Abrons and later developed by Google.

13.what is the difference between AngularJS and backbone.js?

AngularJS combines the functionalities of most of the 3rd party libraries, it supports individual functionalities required to develop HTML5 Apps.  While Backbone.js do their jobs individually.

14.What is DI (Dependency Injection) and how an object or function can get a hold of its dependencies?

DI or Dependency Injection is a software design pattern that deals with how code gets hold of its dependencies. In order to retrieve elements of the application, the operation “config” uses dependency injection which is required to be configured when the module gets loaded.

The ways that object use to hold of its dependencies are:
Typically, dependency can be created using the new operator.
Dependency can be looked up, by referring to a global variable.
Dependency can be passed to where it is required.

15. What are the major browsers Supported by Angular js?

Here are some major browsers supported by Angular js like:

Mozilla Firefox
Google Chrome
Microsft Edge
IE 10,11
IE Mobile,
Safari, iOS
Android: Nougat (7.0) Marshmallow (6.0)

Read More