Exception: SyntaxError: expected expression, got ‘<' Because there is stray tag. When we fix that there goes:Exception: ReferenceError: y is not defined Because you declare var Y but use y. After we fix that bug we’ll see: 1undefinedYour questions are either careless or diabolically hard.Q45 Exception: SyntaxError: unexpected token: identifier Delete != delete Exception: SyntaxError: unexpected token: identifier X != x Exception: ReferenceError: output is not defined Output != output And after all these fixes we got 0 in console.Why do you care so little about code?Q46 Output != output X.Foo != X.fooQ47 Exception: SyntaxError: unexpected token: identifier Because there is missing ; Should be: delete Emp1.company; Exception: ReferenceError: employee is not defined Employee != employeeEmp1 != emp1Exception: ReferenceError: Console is not definedAnd after all these fixes we get xyzQ48 Exception: SyntaxError: unexpected token: identifier is it Function or function? Who knows… Fix that and no error. No output also. Needs console.log(typeof Bar()); And then output number… Why? Because this works. Function can have one name, but many aliases…Dude, it’s 2019! Why are you teaching people like this??? Show This article summarizes a list of Angular interview questions that I would ask candidates and that I get often asked in interviews. Angular is an application design framework and development platform for creating efficient and sophisticated single-page apps. Angular is built entirely in TypeScript and uses it as a primary language. As it is a framework it has many useful built-in features like routing, forms, HTTP client, Internationalization (i18n), animations, and many more. Vue.js and React are no application frameworks but JavaScript libraries to build user interfaces. Vue.js describe itself as Check the Angular blog for latest release notes, for example, the Angular 11 release.
Dependency Injection (DI) is an important design pattern in which a class does not create dependencies itself but requests them from external sources. Dependencies are services or objects that a class needs to perform its function. Angular uses its own DI framework for resolving dependencies. The DI framework provides declared dependencies to a class when that class is instantiated. Angular heavily relies on RxJS, a library for composing asynchronous and callback-based code in a functional, reactive style using Observables. RxJS introduces Observables, a new Push system for JavaScript where an Observable is a producer of multiple values, "pushing" them to Observers (Consumers). ObservablePromiseThey can be run whenever the result is needed as they do not start until subscriptionExecute immediately on creationProvides multiple values over timeProvides only one valueSubscribe method is used for error handling which makes centralized and predictable error handlingPush errors to the child promisesProvides chaining and subscription to handle complex applicationsUses only .then() clause
An Angular component should focus on presenting data and enabling the user experience. It should mediate between the application logic (data model) and the view (rendered by the template). Angular services help us to separate non-view-related functionality to keep component classes lean and efficient. You must register at least one provider of any service you are going to use. A service can be provided for specific modules or components or it can be made available everywhere in your application.
Angular creates a single, shared instance if a service is provided at root level. This shared instance is injected into any class that asks for it. By using the 1 metadata, Angular can remove the service from the compiled app if it isn't used.Registering a provider with a specific NgModule will return the same instance of a service to all components in that NgModule if they ask for it.
A new instance of a service is generated for each new instance of the component if you register the provider at component level.
Directives add behavior to an existing DOM element or an existing component instance. The basic difference between a component and a directive is that a component has a template, whereas an attribute or structural directive does not have a template and only one component can be instantiated per an element in a template. We can differentiate between three types of directives:
Angular provides two ways to compile your app. The compilation step is needed as Angular templates and components cannot be understood by the browser therefore the HTML and TypeScript code is converted into efficient JavaScript code. When you run the 2 or 3 CLI commands, the type of compilation (JIT or AOT) depends on the value of the 4 property in your build configuration specified in 5. By default, 4 is set to true for new CLI apps.JIT compiles your app in the browser at runtime. This was the default until Angular 8. AOT compiles your app at build time. This is the default since Angular 9.
By default, NgModules are eagerly loaded, which means that as soon as the app loads, so do all the NgModules, whether or not they are immediately necessary. For large apps with lots of routes, consider lazy loading—a design pattern that loads NgModules as needed. Lazy loading helps keep initial bundle sizes smaller, which in turn helps decrease load times. After your application instantiates a component or directive by calling its constructor, Angular calls the hook methods you have implemented at the appropriate point in the lifecycle of that instance. Angular calls these hook methods in the following order:
ViewChild and ContentChild are used for component communication in Angular, for example, if a parent component wants access to one or multiple child components.
In Angular exist two different DOMs:
Both types of modules can help to modularize code and Angular relies on both kinds of modules but they are very different. A JavaScript module is an individual file with JavaScript code, usually containing a class or a library of functions for a specific purpose within your app. NgModules are specific to Angular and a NgModule is a class marked by the 8 decorator with a metadata object.
Please read my article The Last Guide For Angular Change Detection You'll Ever Need for a detailed explanation.  Component CSS styles are encapsulated into the component's view to avoid styling side effects in the rest of the Angular application. The type of encapsulation can be controlled per component via the 1 property in the component metadata:
You can choose between the following modes:
I hope this list of Angular interview questions will help you to get your next Angular position. Leave me a comment if you know any other important Angular interview questions. |