Categories
AJAX Angular CSS CSS3 HTML HTML5 JavaScript jQuery NodeJS UI

UI Architect Interview Questions and Answers

what is tail call optimization ?
TCO (Tail Call Optimization) is the process by which a smart compiler can make a call to a function and take no additional stack space.

Recursive function approach has a problem. It builds up a call stack of size O(n), which makes our total memory cost O(n). This makes it vulnerable to a stack overflow error, where the call stack gets too big and runs out of space. Tail Cost Optimization (TCO) Scheme. Where it can optimize recursive functions to avoid building up a tall call stack and hence saves the memory cost.

what is Map, Set, WeakMap and WeakSet ?
Map is a collection of keyed data items, just like an Object. But the main difference is that Map allows keys of any type.

A Set is a collection of values, where each value may occur only once means it will contain unique set of keys. 

WeakSet is a special kind of Set that does not prevent JavaScript from removing its items from memory. WeakMap is the same thing for Map.
WeakMap does not support iteration and methods keys(), values(), entries(), so there’s no way to get all keys or values from it.

Map – is a collection of keyed values.

The differences from a regular Object:

Any keys, objects can be keys.
Iterates in the insertion order.
Additional convenient methods, the size property.
Set – is a collection of unique values.

Unlike an array, does not allow to reorder elements.
Keeps the insertion order.
Collections that allow garbage-collection:

WeakMap – a variant of Map that allows only objects as keys and removes them once they become inaccessible by other means.

It does not support operations on the structure as a whole: no size, no clear(), no iterations.
WeakSet – is a variant of Set that only stores objects and removes them once they become inaccessible by other means.

Also does not support size/clear() and iterations.
WeakMap and WeakSet are used as “secondary” data structures in addition to the “main” object storage. Once the object is removed from the main storage, if it is only found in the WeakMap/WeakSet, it will be cleaned up automatically.

how to do peer to peer communication in ANgular ?

what is directive & components in angular ?

if loop functions are removed from script, how can you achieve same functionality ?

how to drop both data and collection in mongodb ?

what is generic types in Typescript ? advantages ?

how to define custom types in Typescript ?

how to capture the process specific exceptions in NodeJS ?

how do you print name of file currently executing in NodeJS ?

how to use custom pipes in Angular ? can you pass additional parameters in custom pipes ?

what is the max data can be stored in a mongodb document ?

how to acheieve variable length documents in mongodb ?

how do you set autoincrement field in mongodb ?

what is the difference between throttling & debouncing ?
Throttling enforces a maximum number of times a function can be called over time. As in “execute this function at most once every 100 milliseconds.”
Debouncing enforces that a function not be called again until a certain amount of time has passed without it being called. As in “execute this function only if 100 milliseconds have passed without it being called.”

what is event bubbling ? how to stop ?
what is digest cycle in angularJS ?
how to stop propgation ?
what is interpolation ? how does it work ?
what is shadow dom ?
what is webworker ?
how to cache the page/data in HTML 5 ?
how to give offline view expereince in HTML5 ?
what is lazyloadng? how it works ?
what are pure / impure pipes ?
what is redux ? how does it work ?
unit testing code coverage how to check ?
what tool used for unit test ?
streaming , how does it work ?
any custom video/audio player developed?
how does cache works in HTML5 ?
what is method chaining ?
difference between canvas vs SVG ?
what is XSS and how to avoid it ?

difference between Responsive and Adaptive design ?
diff b/w flexbar & grid designs ?
what is cors ? how to allow ?
symmetric & asymetric keys ?
scope usage in OAuth token ?
explain component lifecycle
how to use service in Angular ?
what is event emitters ?
latest ECMA version ?
INPUT & OUTPUT variables usage in Angular
explain Digest Lifecycle in Angular ?
difference between Angular 1.x & Angular 2.x
what is SASS & SCSS ?
what is ViewChild ? OR ViewCildren ?

Explain the following :

Directives,
decorators,
Services,
Modules,
Data Binding,
Components,
Filters,
DOM ,
Events ,
Routing,
Dependency injection.

Categories
Agile AJAX Angular CSS CSS3 HTML HTML5 JavaScript jQuery NodeJS UI

Javascript / UI / Angular Architect Questions and Answers

1.Difference between var let and const. ?

a. Var is hoisted in JS, let and const are not hoisted.

b. Let, const are block level, var is function level The candidate has to tell at least one of these apart from any other difference he tells.

2. What is a closure and how does it work

a. A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain.

A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain.

3. What is a JavaScript class

a. ES 6 standard introduced classes in JS, which internally use the prototypal approach to implement Class .

4. How does JS implement inheritance

a. JS uses prototypal inheritance in which objects inherit properties from other objects (or) JS uses prototypes to implement inheritance

5. What is the difference between == and === in JS

a. == checks only for the value, where === checks for both value and data type

6. What is the use of hasOwnProperty method in JS

a. This method returns true, only when the passed property is present directly on the object.

7. Explain call, apply and bind

a. Call and apply are used to invoke a method, by setting the context of ‘this’ keyword. Call takes comma separated individual parameters, and apply takes array of parameters as arguments

b. Bind method does the same operation as call and apply, but returns a new function definition instead of invoking the method

8. What is ‘arguments’ keyword in JS

a. Arguments is a special property in every function, that holds all the parameters passed to that function. Its an array-like object.

9. What is arrow function

a. Arrow function is introduced in ES 6 standard of JS, and does implicit binding of this property.

10. What are benefits of TypeScript

a. * TS provides type safety for the variables

Skills checked:

JS core – Intermediate / Advanced

  1. What is a closure and how it works in JavaScript
  2. What is a ‘hosting’ , How this works in JavaScript ?
  3. call, apply and bind with example
  4. Event bubbling and Event capturing
  5. event delegation
  6. prototypical inheritance / prototypical chain
  7. strict mode and usual mode
  8. What is EventLoop?

ECMA

  1. Difference between var, let and const?
  2. What is a promise and how it works?
  3. What is a arrow function and its difference from function syntax?
  4. Generator and how it works
  5. JS modules, export and export default
  6. async/await

Angular – Intermediate / Advanced

  1. Virtual DOM concept.
  2. Subscribe, Observables and Promises.
  3. Different ways of data bindings.
  4. Sequence of Angular Lifecycle Hooks
  5. Routing
  6. Reactive Forms.

React JS and Redux – Novice / Intermediate

  1. Virtual DOM concept.
  2. Explain lifecycle of React component.
  3. Difference between state and props.
  4. Redux
  5. Role of reducer

HTML – Novice / Intermediate

  1. What is a Doctype?
  2. quirks mode and standart mode
  3. new features in html5
  4. Html storage Localstorage and sessionstorage

CSS – Novice

  1. Difference between adaptive and responsive design?
  2. What is a repaint and reflow?
  3. Media query.
  4. Layout Methodology.
  5. How browser search selector?

Networking – Intermediate

  1. What is REST?
  2. REST principles.
  3. Difference between POST and PUT requests

Design Patterns – Advanced

  1. Factory Patterns
  2. Singleton Patterns

Unit testing

  1. TDD/BDD
  2. jasmine/karma

Processes

  1. GIT
  2. Code review process and tools
  3. CI/CD
  4. SOLID
  5. SCRUM
  6. Webpack
  7. IDE

Categories
AJAX Angular CSS HTML HTML5 JavaScript jQuery NodeJS UI Uncategorized VueJS XML

UI Developer – Angular JS INTERVIEW Question and Answer | UI Lead Angular

Migration from any other to MEAN/Angular PROS and CONS ?
checklist for new RFP ? what are all things will be considered for RFP response ?
checklist for development ? deployment ?
coding standard guidelines what is followed ? any libraries integrated ?
For live release of an existing site, how to manage the deployment of new functionality ? without affecting the existing site.
Tools used for code review in Agile ?

If ABC are angular components and  A is parent and B is child and  c is child of child.   how do you delegate event directly from C to A. ?

What is dependency injector ?

What is RxJs ?

explain http response of angular 4.3.2 ?
explain observable response in Angular ?

Difference between http / httpclient in angular ?

what is interceptor ?

what is service injector ?  how to pass authentication specific credentials using injector ?

what is message queue  ?
explain any project with nosql experience  ?

Categories
AJAX Angular HTML HTML5 JavaScript jQuery NodeJS UI VueJS

Angular Interview Questions and Answers | UI Architect Advanced Level Questions

Angular Interview Questions and Answers | UI Architect Advanced Level Questions

How to write Custom Filter in Angular ?

Angular exposes a simple API for creating a filter. similiar to controller declaration with syntax  app.controller(‘myCtrl', function(){});, you can create a new filter by appending .filter(‘filterName', function(){}) to your Angular application. A filter is very similar to a factory or service but has a global scope once its created.You can invoke a filter on both the data binding in your html or directly inside of your controller or directive by using the $filter service.

Function to find the longest word in a sentence ?
First take string sentence and convert this into a array using split()  with separator as space (‘ ‘).

const stringArray = str.split(" ");

And than pass this array into custom sort function to sort based on the word length.

function findLongestWord(str) {
  const stringArray = str.split(" ");
  const orderedArray = stringArray.sort((a, b) => {
    return a.length < b.length;
  });
  return orderedArray;
}

Now just return the  first word (0-index of the array) of the array which contains longest word of the sentence.

Difference between service & factory in Angular ?

The difference between factory and service is just like the difference between a function and an object

Factory Provider

  • Gives us the function’s return value ie. You just create an object, add properties to it, then return that same object.When you pass this service into your controller, those properties on the object will now be available in that controller through your factory. (Hypothetical Scenario)
  • Singleton and will only be created once
  • Reusable components
  • Factory are a great way for communicating between controllers like sharing data.
  • Can use other dependencies
  • Usually used when the service instance requires complex creation logic
  • Cannot be injected in .config() function.
  • Used for non configurable services
  • If you’re using an object, you could use the factory provider.
  • Syntax: module.factory('factoryName', function);

Service Provider

  • Gives us the instance of a function (object)- You just instantiated with the ‘new’ keyword and you’ll add properties to ‘this’ and the service will return ‘this’.When you pass the service into your controller, those properties on ‘this’ will now be available on that controller through your service. (Hypothetical Scenario)
  • Singleton and will only be created once
  • Reusable components
  • Services are used for communication between controllers to share data
  • You can add properties and functions to a service object by using the this keyword
  • Dependencies are injected as constructor arguments
  • Used for simple creation logic
  • Cannot be injected in .config() function.
  • If you’re using a class you could use the service provider
  • Syntax: module.service(‘serviceName’, function);

AngularJS .service


module.service('MyService', function() {

    this.method1 = function() {
            //..method1 logic
        }

    this.method2 = function() {
            //..method2 logic
        }
});

AngularJS .factory


module.factory('MyFactory', function() {

    var factory = {}; 

    factory.method1 = function() {
            //..method1 logic
        }

    factory.method2 = function() {
            //..method2 logic
        }

    return factory;
});

Explain CSS position attribute ?

The position property specifies the type of positioning method used for an element (static, relative, absolute, fixed, or sticky).

static Default value. Elements render in order, as they appear in the document flow
absolute The element is positioned relative to its first positioned (not static) ancestor element
fixed The element is positioned relative to the browser window
relative The element is positioned relative to its normal position
sticky The element is positioned based on the user’s scroll position
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Explain Isolate Scope in Angular ?
Scope in AngularJS inherits from Parent Scope by default. Isolated scope does not inherit from the parent scope by default. It can access its parent scope through the $parent property.  So, Directive has three options for isolating its scope from parent scope. The following are the three options:

  1. scope: false  It is default in Directive. It lets to reuse the scope from the place where the component is being used.
  2. scope: true – It creates a child scope. This child scope prototypically inherits from the scope where the component is being used.
  3. scope: {…} – It creates Isolates scope. It does not prototypically inherit from the scope where the component is being used.

Isolated scope completely decouples component or template from the rest of the application or a place where it is being used.

There are three types of interface to specify between the element’s attributes and the isolated scope:
  1. interpolate (@)
  2. data bind (=)
  3. expression (&)
Attributes or Interpolate (@)
An Isolated scope property can be bind with DOM attributes. Interpolate or attribute sets up a one-way data binding from the Parent scope to the Isolated Scope of Directive.
Binding (=)
Binding works almost exactly like the attribute except that it provides two-way mode binding.
Expression (&)
Expression is used to call a function on the Parent scope from the Isolated Scope.

Explain angular Prototype ? 

 

Difference between async and defer tags in Javascript ?
Defer and Async tags are available only for external scripts (with src=”” tag). If you will try to use them for internal scripts like <script>…</script> tags, defer and async will be ignored.
Adding an async tag to the JavaScript code , so that creation of the DOM model happens in parallel, and won’t be interrupted while the JavaScript is loading and executed.
Adding a defer tag with JavaScript code, it will not stop loading the DOM and CSSOM models. All scripts with a defer tag will be loaded and run immediately after the DOM and CSSOM models are completed. Any scripts will be loaded in the order you code.

What is Event delegation in JS ?
JavaScript event delegation is a simple technique by which you add a single event handler to a parent element in order to avoid having to add event handlers to multiple child elements.

What is Closure in JS ?
A closure is basically when an inner function has access to variables outside of its scope. Closures can be used for things like implementing privacy and creating function factories.

What is Debouncing & Throttling in JS ?
Debouncing is one way to solve the issue of same function calling multiple times on event action, by limiting the time that needs to pass by until a function is called again.

Throttling is another technique that’s is similar to debouncing, except that instead of waiting for some time to pass by before calling a function, throttling just spreads the function calls across a longer time interval.
So if an event occurs 10 times within 100 milliseconds, throttling could spread out each of the function calls to be executed once every 2 seconds instead of all firing within 100 milliseconds.

Difference between  TDD vs BDD ?
In TDD (Test Driven Development), the test is written to check the implementation of functionality, but as the code evolves, tests can give false results. BDD (Behavior Driven Development) is also a test-first approach, but differs by testing the actual behavior of the system from the end users perspective.

 

Categories
Angular CSS CSS3 HTML HTML5 JavaScript NodeJS UI

UI Developer / Lead / Architect Interview Question and Answers – Part 2

UI Developer / Lead / Architect Interview Question and Answers – Part 2

Type of components in Angular ? 

There are two types of components in Angular 


– Declarative components  

these components are  which are included in the template


– Entry components 

Any component that Angular loads imperatively and you’re not referencing it in the template. 



what is entry components in modules  ?


An entry component is any component that Angular loads imperatively, (which means you’re not referencing it in the template), by type. 

You specify an entry component by bootstrapping it in an NgModule, or including it in a routing definition. 


There are two main kinds of entry components:


The bootstrapped root component.

A component you specify in a route definition.


Explain the process to do for popup in Angular material design ?   

The Angular Material library offers support for displaying modal dialogs in Material Design. 

To enable Angular Material Dialogs in your Angular application you need to import MdDialogModule in your main application module.

Next, make sure to also add MdDialogModule to the imports array of @NgModule

Make use of the MdDialog service which is part of MdDialogModule in our components

create a new component using cmd “ng g component DialogDemo”

which creates 4 files  html / css / ts / spec.ts  as below 


src/app/dialog-demo/dialog-demo.component.css

src/app/dialog-demo/dialog-demo.component.html

src/app/dialog-demo/dialog-demo.component.spec.ts

src/app/dialog-demo/dialog-demo.component.ts



In dialog-demo.component.html file add html code for modal popup display code using MdDialog, MdButton and MdCard elements and directives. 

import {MdCardModule} from ‘@angular/material’;

import {MdButtonModule} from ‘@angular/material’;

import {MdDialogModule} from ‘@angular/material’;


And add the types to the imports array also :

imports: [

BrowserModule,

BrowserAnimationsModule,

MdCardModule,

MdButtonModule,

MdDialogModule

  ],

  

  

add the component selector to the markup code of our main application component in file app.component.html. 

<app-dialog-demo></app-dialog-demo>

Now you can customize the code based on the actions/events/data sharing etc.. in the modal (Dialog) popup component/services in ts files. 



what is the criteria to choose on JS frameworks ? 

There are many criteria when it comes to choosing a JS framework like 

Functionality , Usability, Reliability, Efficiency, Maintainability and Portability 

and also finalize based on the 

Project requirements suitability 

Browser Support {typically with Safari on the Mac} 

Strength of development team supporting the framework.

Maturity of the framework

Frequency of public updates and releases.

Documentation quality.

Existence of an active community.

Benchmark tests on performance aspects

Extensibility of the framework with Plugin support 

API Style Support 

Commericial Support availablity 

and functionalitywise support like 


DOM navigation/manipulation

Basic UI components support

Advanced UI widget library

Themes and skinning support

Validations support

Ease of server interaction

Multiple data exchange formats support 

how to trigger LazyLoading feature in AngularJS ?

we need lazy loading to improve the performance of loading time of the application. 

Instead of loading all components at first time , in angular we can split this into children and load it whenever required.

Lazy Loading is load only what we need to use when first starting up the application. 

If user navigate to a new page, then the component for that page will load immediately.


Lazy loading is performed by allowing the router config to provide the module to load on route execution. 

To utilize lazy loading you must split your code into modules.

In the app.router.ts you will have the special router called loadChildren, this is used for lazy loading module 

and it accepts value as a string. 

The path of the loadChildren is based on src directory, you need to provide the full path of your feature module 

and put the ‘#’ sign then your export module class name.

Finally, we need to import the app.router.ts that is root router of the application to the app.module.ts.


how to do State Management in AngularJS  ? 

State Management OR Managing state means need to coordinate multiple backends, web workers, and UI components, all of which update the state concurrently. 

Patterns like Redux and Flux are designed to address this problem by making this coordination more explicit.

A typical web application has the following six types of state:


Server state

Persistent state

The URL and router state

Client state

Transient client state

Local UI state


Backend manages the server state, persistent state (the talks) and the client state (the filters).

The router manages the URL and the router state.

WatchService manages the transient client state (watched talks).

The individual components manage the local UI state.


and maintaining / synchronizing these states across the application using custom observers OR usnig tools like Redux. 


what is content in angular ?

Transclusion in AngularJS OR Content Projection in Angular is a way to let you define a fixed view template, and 

at the same time allow you to define a slot for dynamic content by using <ng-content> tag.

and using the type of selector like Attribute, HTML tag, or CSS class etc.. you can load the dynamic content in the ng-content directive section. 

Whenever some libraries conflict issues are coming , how do you solve ?

You can avoid the conflicts with other libraries using namespaces OR Alias like jQuery noConflict method. 

OR 

if libraries are managed using packages.json than using peerDependencies package attribute you can manage multiple versions of files.


Difference between routing and templating ? 

Routing -> To navigate to different pages in the application with no page reloading we use Angular Routing using ngRoute module.

The ngRoute module routes your application to different pages without reloading the entire application.


Templating -> templating allows you to create one master page for the structure and then just replace pieces of the page with different content based on the url.


AngularUI Router -> The UI-Router is a routing framework for AngularJS provides a different approach than ngRoute in that it changes your application views based on state of the application and not just the route URL. 



Difference between unidirectional data binding and bidirectional data binding ? 

One way binding is bind the data from model to view. 

Where as two way binding is bind the data from model to view and view to model. 

Data flows from the Scope/Controller to the View and from the View to the scope/controller). 

‘ng-model’ is an angular directive used for achieving two-way data binding.



Difference between responsive and adaptive design ? 

Responsive sites and adaptive sites are the same in that they both change appearance based on the browser environment , size, device etc…


Responsive Web Design makes your web page look good on all devices (desktops, tablets, and phones). 

Responsive Web Design is about using HTML and CSS to resize, hide, shrink, enlarge, or move the content to make it look good on any screen. 

Fluid grids, flexible images, and media queries are the three technical ingredients for responsive web design.


Adaptive design detects the device and other features and then

provides the appropriate feature and layout based on a predefined set of viewport sizes and other characteristics 



Difference b/w Javascript vs ES5 or ES6 ? 

scripting language is a programming language designed specifically for acting on an existing entity or system. 

ECMA means European Computer Manufacturer’s Association  ECMAScript (ES)  –>  Is the specification defined in ECMA-262 for creating a general purpose scripting language. 

ECMAScript provides the rules, details, and guidelines that a scripting language must observe to be considered ECMAScript compliant.


JavaScript (JS)  –> A general purpose scripting language that conforms to the ECMAScript specification. 

JavaScript mostly implements the ECMAScript specification as described in ECMA-262. 


A JavaScript engine –> A program or interpreter that understands and executes JavaScript code. 

JavaScript engines are commonly found in web browsers, including V8 in Chrome, SpiderMonkey in Firefox, and Chakra in Edge. 


ECMAScript 5 –> 

It is the fifth edition of the ECMA-262 standard, and major features of the ECMAScript specification. 


ECMAScript 6  –> 

It is the sixth edition of the ECMA-262 standard, and features major changes and improvements to the ECMAScript specification.


Babel

A transpiler that can convert ES6 code to ES5 code.



Which is First ? Chicken or  Egg — ECMAScript or JavaScript 

A confusing bit of history is that JavaScript was created in 1996. It was then submitted to Ecma International in 1997 for standardization, which resulted in ECMAScript. At the same time, because JavaScript conformed to the ECMAScript specification, JavaScript is an example of an ECMAScript implementation.

ECMAScript is based on JavaScript, and JavaScript is based on ECMAScript.

To read more on this topic, here is the best article resource : https://www.toptal.com/angular/angular-components-overview-101

Categories
DRUPAL HTML HTML5 JavaScript jQuery LAMP MySQL PHP

PHP ARCHITECT QUESTIONS AND ANSWERS

What’s the difference between  <SPAN> and  <div> tags?
Span is for inline elements. Div is for block elements.
<div>tags are block elements that allow you to position elements contained within block.
tags used for inline styling of text.
<div> tags create line breaks, <span> tags doesn’t.
div elements are placed in a row, in other words automatic break is inserted. Whereas in case of span elements all are coming one after the other without any breaks.
Note: Can change inline element into block level element through CSS and vise-versa.
div{display:inline}
span{display:block}
Explain Data encryption in PHP ?
The PHP crypt() function can be used to encrypt data.
MD5 is a one way HASH
base64_encode is for encoding data.
Echo, print, printf – what is the difference between these?
Print and echo both output what is passed to them. Print acts like a function, so you can use it in complex statements. Printf is used to format the output
how variables are passed to functions by reference and by value?
A variable is passed by value unless the variable is passed with an &, such as functionName(&$variableName)
How can I execute a PHP script using command line?
PHP script using command line can be executed using SAPI
(Server Application programming Interface). Using SAPI
Command Line Interface the PHP code can be passed to execute
directly
Example:
Php –r ‘print_r(get_defined_constanrs());’
php filename
From a shell/cmd prompt, php –v will display whether the SAPI is CLI or CGI
explain YAHOO’s 20 points for web performance optimization ?
1. Flush the buffer early [server]
2. Use GET for AJAX requests [server]
3. Post-load components [content]
4. Preload components [content]
5. Reduce the number of DOM elements [content]
6. Split components across domains [content]
7. Minimize the number of iframes [content]
8. No 404s [content]
9. Reduce cookie size [cookie]
10. Use cookie-free domains for components [cookie]
11. Minimize DOM access [javascript]
12. Develop smart event handlers [javascript]
13. Choose <link> over @import [css]
14. Avoid filters [css]
15. Optimize images [images]
16. Optimize CSS sprites [images]
17. Don’t scale images in HTML [images]
18. Make favicon.ico small and cacheable [images]
19. Keep components under 25K [mobile]
20. Pack components into a multipart document [mobile]
FMI : http://developer.yahoo.com/performance/rules.html
What are all the new changes in PHP6 ?
Here is the list :

  1. FILE_BINARY and FILE_TEXT constants available for use with filesystem functions.
  2. register_globals will be gone.
  3. magic_quotes will also disappear.
  4. $HTTP_*_VARS has been removed, in favour for $_GET, $_POST, etc.
  5. ereg() no longer available in core PHP6.
  6. Initiating objects with the reference operator (& new Object()) will generate E_STRICT error.
  7. E_STRICT error messages are included in E_ALL errors.
  8. {} for string offsets no longer available.
  9. [] un-deprecated for accessing characters in a string.
  10. ASP-style tags can no longer be used.
  11. Better Unicode Support.
  12. var will be an alias of public, and raises E_STRICT warning.
  13. Support for 64 bit integers.
  14. With ternary operator, the “true” expression is no longer required – this can be done: $a = $s ?: ‘b’; (Not clear yet exactly how this will work).
  15. zend.ze1_compatibility_mode removed.
  16. safe_mode is being removed.
  17. Freetype1 and GD1 support removed.
  18. dl() is only enabled when a SAPI layers registers it explicitly.
  19. Support for dynamic break levels removed.
  20. XMLReader and XMLWriter will be in the core distribution.
  21. mime_magic removed from the core.
  22. Fileinfo moved to the core.
  23. ext/soap on by default.
  24. foreach supports multi-dimensional arrays: foreach($a as $b => list($c, $d))
  25. microtime() will return as float by default.
  26. opcode cache included in core distribution, but turned off by default.
  27. flags parameter available for file_get_contents().
  28. before_needle parameter added to strstr() – allows strstr() to return part of haystack before occurence of the needle.
  29. namespace, import, and goto become reserved words.

FMI : http://blog.tuvinh.com/one-minute-with-php6/

Categories
AJAX Angular CSS CSS3 HTML HTML5 JavaScript jQuery NodeJS UI Uncategorized VueJS

SAP – UI Architect – Angular Interview Questions and Answers

List and explain XSS attack types?

Cross-site scripting (XSS) is a code injection attack that allows an attacker to execute malicious JavaScript in another user’s browser.

XSS attacks are of three types:

  • Persistent XSS, where the malicious string originates from the website’s database.
  • Reflected XSS, where the malicious string originates from the victim’s request.
  • DOM-based XSS, where the vulnerability is in the client-side code rather than the server-side code.

Methods of preventing XSS

  • Encoding, which escapes the user input so that the browser interprets it only as data, not as code.
  • Validation, which filters the user input so that the browser interprets it as code without malicious commands.

What is CORS , how to manage? How to secure the requests?

Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell a browser to let a web application running at one origin (domain) have permission to access selected resources from a server at a different origin. A web application makes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, and port) than its own origin.

two response headers are most important for security:  

  • Access-Control-Allow-Origin specifies which domains can access a site’s resources. For example, if ABC Corp. has domains ABC.com and XYZ.com, then its developers can use this header to securely grant XYZ.com access to ABC.com’s resources. 
  • Access-Control-Allow-Methods specifies which HTTP request methods (GET, PUT, DELETE, etc.) can be used to access resources. This header lets developers further enhance security by specifying what methods are valid when XYZ accesses ABC’s resources. 

As CORS can lead to multiple security vulnerabilities , so instead of allowing CORS use a trusted server as a proxy / reverse proxy and allow all requests/resources to be served  from that dedicated server.

What is Virtual polymorphism ?

Polymorphism is the ability for objects of different classes related by inheritance to respond differently to the same member function call.

virtual function allows a programmer to call a function and let the program determine dynamically which version of the function to use.
To enable this type of behavior, the function will be declared in the base class as a virtual function and then be redefined in each of the derived classes.
To declare a virtual function, precede the function’s prototype with the keyword virtual in the base class.
Combination of both Virtual Function with polymorphism concept is called Virtual Polymorphism.

Write a Sql query for products table to get total price of products sold in a quarter ?

 SELECT
  productname, 
  SUM(price) as total_count
  FROM products
  WHERE `date` >= startdate AND `date` <= enddate
  GROUP BY productname
  ;

Write a Sql query for products table to get total price of products sold in a quarter ?

To calculate any factorial in real-time, you can speed it with a cache, saving the numbers you’ve calculated before.

factorial = (function() {
    var cache = {},
        fn = function(n) {
            if (n === 0) {
                return 1;
            } else if (cache[n]) {
                return cache[n];
            }
            return cache[n] = n * fn(n -1);
        };
    return fn;
})();

Types of requests which can be handled through browser?

HTTP, HTTPS, FILE, and FTP protocols are supported by most of the commonly used browsers.

What is promise? Advantages of it ?

A Promise is an object representing the eventual completion or failure of an asynchronous operation. Essentially, a promise is a returned object to which you attach callbacks, instead of passing callbacks into a function.

Advantages of promises are

  • Callbacks will never be called before the completion of the current run of the JavaScript event loop.
  • Callbacks added with then() even after the success or failure of the asynchronous operation, will be called, as above.
  • Multiple callbacks may be added by calling then() several times. Each callback is executed one after another, in the order in which they were inserted.
  • One of the great things about using promises is chaining.

How to improve the Performance of webpage?

  • Reduce External HTTP Requests
  • Minify CSS, JS and HTML
  • Compress Components with Gzip
  • Optimize Your Images
  • Add CSS at top/header section
  • Add JS at bottom section
  • Reduce DNS Lookups
  • Use CDN and Cache
  • Make Fewer HTTP Requests
  • Avoid empty src or href
  • Add Expires Headers
  • Avoid CSS Expressions
  • Avoid URL Redirects
  • Remove Duplicate JavaScript and CSS
  • CleanUP the unecessary code
  • Configure Entity Tags (ETags)
  • Reduce the Number of DOM Elements
  • Avoid HTTP 404 (Not Found) Error
  • Do Not Scale Images in HTML
  • Make favicon Small and Cacheable

IF Request/Response taking too much time than How to keep alive the request ?

A Request/Gateway Timeout response code indicates that the server did not receive a complete request from the client within a specific period of time tracked by the server.
You can set custom timeout for your http request in the second parameter of http.get() method:
$http.get(‘request-path’, {timeout: 300000});
This will set timeout to 300 seconds = 5 minutes. Increasing it to something much larger should help.
OR
req.setTimeout(0) for no timeout for all requests
Another solution is doing a long polling or short polling to keep alive the request.

DB 2 queries same record update? How to manage? How to intimate the second request to update itself?

Use SQL transaction statements like BEGIN and COMMIT to avoid concurrent updates to same record.
OR
You may have additional field which indicates that column is being edited. When first user starts work, the field would be updated. The second user would query object with ‘on hold’ status and your code would handle this.

Lot of requests , how to manage?

  • Use CDN for optimized content delivery
  • Use Cache Layers like memcache , redis etc..
  • Use Load Balancing techniques for Application Servers / Cache Layers
  • Use Master / Salve configuration for DB Servers

Same application, for 2 different companies but for all users, request to come, how to manage?

Use Proxy / Reverse proxy configuration along with a flag specific to company to manage the requests to handle internally from different servers.

Bind, apply and call difference in angular ?

The bind() method creates a new function that, when called, has its “this” keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.
fun.bind(thisarg[, arg1[,arg2[,….]]])

Function.call allows us to set the this value of a function manually. Instead of simply calling a function like fn(), we use fn.call(param), passing in the object we want this to equal as the parameter.
call also allows us to pass in parameters to the function being called. Anything given after the object to be bound to thiswill be passed along to the function.

Function.apply works the same exact way as call, except instead of passing in arguments one by one, we pass in an array of arguments that gets spread into the function.

In call method parameter will be passed separately. whereas in apply you can pass parameters as Array arguments.

Globalization or internationalization , how to do in angular?

Internationalization (i18n) is the process of developing products in such a way that they can be localized for languages and cultures easily. Localization (l10n), is the process of adapting applications and text to enable their usability in a particular cultural or linguistic market.
internationalizing an application means abstracting all of the strings and other locale-specific bits (such as date or currency formats) out of the application. Localizing an application means providing translations and localized formats for the abstracted bits.
AngularJS supports i18n/l10n for date, number and currency filters.
Localizable pluralization is supported via the ngPluralize directive.
All localizable AngularJS components depend on locale-specific rule sets managed by the $locale service.

How to avoid same button multiple clicks  ?

There are multiple ways to avoid multiple clicks of a same button

  • Once the click event is fired , disable the button till event response is processed
  • Unbind the click event on first click event
  • Provide a time interval for between the same object click event
Categories
Angular CSS HTML HTML5 JavaScript NodeJS UI VueJS

UI Developer / Lead / Architect Interview Question and Answers

UI Developer / Lead / Architect Interview Question and Answers 

1) SASS vs LESS  which is better ? 

SASS is better and more reliable, flexible and most of the modern JS frameworks are using SASS for more feature availability.   

2)  List 4 types of memory leaks of JS ?

—  Unnecesseary Global Variables 

—  Unused Functions ex: timers  

—  Unnecesseary DOM reference elements 

—  Improper Closures 

—  Manage Garbae collection wherever required

3) backward compatibility  for libraries how to manage ? 

Shared dependencied must be defined in peerDependencies package attribute. 

When both your project and some module you are using depend on the same libraries but different versions than you should define 

project level library dependency in “peerDependencies” section of the package.json to avoid conflicts of multiple version libraries. 

So project dependency library installed in main folder and module specific dependency library will be installed within the module folder

so it will avoid the conflicts. 

4) profiling of pages ?

For web page loading in a browser it has to wait for 

Initialization (DNS resolution, TCP connection, proxy, and SSL negotiation),

Server rendering, 

Data transfer, 

and 

page rendering in the browser

A web page is composed from many resources besides the main contents that the browser has to resolve

 and load (JavaScripts and stylesheets).

 Then it needs to build the DOM tree from the HTML and execute any needed JavaScript

Server side performance can be improved by improving the infrastructure 

such as no: of clusters/servers, CPU, memory, bandwidth, location etc.. 

Client side performance can be improved by following parameters/criteria :

HTTP optimizations -> by Network optiomaizations like DNS/TCP/SSL connections, browser preloaders , Resource Loading time, Content loading time 

HTML and JavaScript loading optimizations -> Google RAIL model

Response (user interface): Tap to paint in less than 100ms;

Animation: Layout rendering should take less than 16ms per frame;

Idle: Use idle time to compute some work in chunks of 50ms;

Load: The page should be fully loaded in less than 1000ms.

Stylesheets optimizations -> 

Minify and Compress your files

Remove unused CSS rules

Optimize the CSS critical path

Analyze Stylesheets complexity

Image caching / sprite images  

Use CDN 

use Cache control expires

Gzip the componets for reduce load 

Stylesheets at TOP / Scripts at Bottom 

Remove duplicate code/scripts 

Use ETags for browser caching 

Profiling tools like : pingdom, google pagespeedtest to implement and optimize the suggestions 

5) how to make lightweight UI  ?  

Color minimalism

Operation simplification with the minimal steps of operation

Layered interface with flat design and skeumorphism

Micro-interaction  like “pull-down refresh”,”add to shopping cart”, etc.

6) How to make Data processing  better & faster ?  

For JS Frameworks 

 — Caching Your App data with cache layers like memcached, Redis etc.. 

 — Multi clustering of Data / Application for faster proecessing  

 — All data processing queries are Optimized

 — Check All Error in the Scripts by Logging and make all error scenarios are handled 

 For Angular 

 — Use Batarang tool to debug and fix any performance issue  

 — Chrome Dev Tool Profiler to Identify Performance Bottlenecks

 — Use console.time for Debugging Issues

 — Use ng-if or ng-switch instead of ng-show

The ng-show directive toggles the CSS display property on a particular element, while the ng-if directive actually removes the element from DOM and re-creates it if needed. 

 — Avoid using ng-repeat

 — Overuse of the ng-repeat directive can drastically drive down performance. 

 — Lower the number of elements that get looped over by implementing pagination or infinite scroll. AngularJS even has a directive called ngInfiniteScroll for that purpose. 

7) what is STRICT mode in JS ? 

 “use strict”; Defines that JavaScript code should be executed in “strict mode” so it will make “bad syntax” into real errors.

Using a variable, without declaring it, is not allowed:

Using an object, without declaring it, is not allowed:

Deleting a variable (or object) is not allowed.

Deleting a function is not allowed.

Duplicating a parameter name is not allowed:

Octal numeric literals are not allowed:

Octal escape characters are not allowed:

Writing to a read-only property is not allowed:

Writing to a get-only property is not allowed:

Deleting an undeletable property is not allowed:

The string “eval” cannot be used as a variable:

The string “arguments” cannot be used as a variable:

The with statement is not allowed:

For security reasons, eval() is not allowed to create variables in the scope from which it was called:

In function calls like f(), the this value was the global object. In strict mode, it is now undefined.

Keywords reserved for future JavaScript versions can NOT be used as variable 

Categories
CSS CSS3 HTML HTML5 JavaScript jQuery

HCL – Web / UI Developer – interview questions and answer – HTML5 , CSS3 , JS & jQuery

1) Explain about HTML5 local storage ?
There are two ways to store data in HTML as objects locally :

  1. localStorage – store data  across session acess
  2. sessionStorage – storing data for current session only

Data will be stored in key/value pair format.
example:
localStorage.empid=”420″;
sessionStorage.companyname = “SHARAG INFOTECH”;
2)  explain CSS media queries ?
CSS media queries are used to develop responsive templates for different layout of screen, print, mobile , tablet or any other resolutions
CSS media queries can be added in 3 ways as like CSS style sheet :

  1. Internal stylesheet :  <style type=”text/css”>
    @media only screen and (max-width: 600px){
    /* rules apply to the device resolution is 480px or less  */
    }
    </style>
  2. Imported stylesheet :   @import “tablet.css”   (min-width: 800px) and (max-width: 1200px);
  3. External stylesheet:  <link rel=”stylesheet” type=”text/css” href=”deskto.css” media=”screen and (min-width: 1200px), print and (min-resolution: 300dpi)” />

3) explain css inheritance ?
Inheritance propagates property values from parent elements to their children. The inherited value of a property on an element is the computed value of the property on the element’s parent element. For the root element, which has no parent element, the inherited value is the initial value of the property.
A property can also be explicitly inherited by using the inherit keyword in property.
CSS inheritance example:
class inheritance for an HTML tag :
<div class=”firstClass secondClass thirdClass fourthClass ” > </div >
CSS property inheritance from parent :
p {
color: #000;
}
p a:link {
color: inherit;
}
and using LESS method for inheritance example:
//through variable
@color: #123456;
#emp {
color: @color;
}
div {
color: @color;
}
//through class name calling [MIXINS]
.rounded-corners (@radius: 2px) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
-ms-border-radius: @radius;
-o-border-radius: @radius;
border-radius: @radius;
}
#navtable {
.rounded-corners;
}
#maintable {
.rounded-corners(5px);
}
4) what is javascript inheritance ?
In simple terms, inheritance is the concept of one thing gaining the properties or behaviours of something else.
Inherited children inherit their parent’s behaviour To say A inherits from B, is saying that A is a type of B.
In JavaScript You must use a special object called prototype.
function Animal() {}; // This is the Animal *Type*
Animal.prototype.eat = function () {
alert(“All animals can eat!”);
};
function Bird() {}; // Declaring a Bird *Type*
Bird.prototype = new Animal(); // Birds inherit from Animal
Bird.prototype.fly = function() {
alert(“Birds are special, they can fly!”);
};
The effect of this is that any Birds you create (called an instance of Bird) all have the properties of Animals
var aBird = new Bird(); // Create an instance of the Bird Type
aBird.eat(); // It should alert, so the inheritance worked
aBird.fly(); // Important part of inheritance, Bird is also different to Animal
var anAnimal = new Animal(); // Let’s check an instance of Animal now
anAnimal.eat(); // Alerts, no problem here
anAnimal.fly(); // Error will occur, since only Birds have fly() in its prototype
5) explain javascript associative array ?
Associative arrays are where we can associate a key string with a value string
JavaScript objects are also associative arrays.
i.e the property  emp.Name can also be read by calling emp[‘Name’]
We can access each property by entering the name of the property as a string into the array
it refers to accessing the DOM elements of HTML also [as object or associative array]
6) explain JS Namespace ?
Namespacing is a technique employed to avoid collisions with other objects or variables in the global namespace
and also helps to organize blocks of functionality into easily manageable groups that can be uniquely identified.
JavaScript doesn’t  builtin support of namespacing but using objects and closures we can achieve a similar effect.
javascript Namespacing patterns :
1)    Single global variables :
var myApplication =  (function(){
function(){
/*…*/
},
return{
/*…*/
}
})();
2)    Object literal notation :
var myApplication = {
getInfo:function(){ /**/ },
// we can also populate our object literal to support
// further object literal namespaces containing anything
// really:
models : {},
views : {
pages : {}
},
collections : {}
};
3)    Nested namespacing :
var myApp =  myApp || {};
// perform a similar existence check when defining nested
// children
myApp.routers = myApp.routers || {};
myApp.model = myApp.model || {};
myApp.model.special = myApp.model.special || {};
// nested namespaces can be as complex as required
4)    Immediately-invoked Function Expressions :
// an (anonymous) immediately-invoked function expression
(function(){ /*…*/})();
// a named immediately-invoked function expression
(function foobar(){ /*..*/}());
// this is technically a self-executing function which is quite different
function foobar(){ foobar(); }
5)   Namespace injection :
// define a namespace we can use later
var ns = ns || {}, ns2 = ns2 || {};
// the module/namespace creator
var creator = function(val){
var val = val || 0;
this.next = function(){
return val++
};
this.reset = function(){
val = 0;
}
}
creator.call(ns);
// ns.next, ns.reset now exist
creator.call(ns2, 5000);
// ns2 contains the same methods
// but has an overridden value for val
// of 5000
for more details on namespace read http://addyosmani.com/blog/essential-js-namespacing/
7) explain Jquery live and bind methods ?
.bind() attacheds events to elements that exist or match the selector at the time the call is made.
Any elements created afterwards or that match going forward because the class was changed, will not fire the bound event.
$(‘img’).bind(‘click’, function(){…});
.live() works for existing and future matching elements.
Before jQuery 1.4 this was limited to the following events:
click, dblclick mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup
$(‘img’).live(‘click’, function(){…});
8) what is bootstrap ?
Bootstrap is an open-source Javascript framework developed by the team at Twitter.
It is a combination of HTML, CSS, and Javascript code designed to help build user interface components.
Bootstrap is Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
Bootstrap was also programmed to support both HTML5 and CSS3
Bootstrap is a CSS and Javascript framework that is used within your HTML. Bootstrap provides more advanced functionality to your web site.
More details http://getbootstrap.com
9) type of webservice ?
there are two types of web service….1. SOAP [Simple Object Access Protocol] Webservice and 2. RESTful [REpresentational State Transfer] Webservice.
SOAP is a messaging protocol , REST is a design philosophy , not a protocol.
SOAP:
you define your interface in a .wsdl file, which describes exactly which input parameters are expected and how the return values will look like
there are tools to generate the .wsdl files out of java class hirarchies. JAXB for example
there are also tools to generate java objects/classes as part of eclipse for example (don’t know the name in the moment).
SOAP is very strict. Every request is validatet against the wsdl before processing.
A good but not so easy to start with framework for SOAP WS is Apache CXF
REST (no hands on experience up to now, feel free to correct and improve 😉 ):
a way to access a webserver or web application to retrieve data from or send to it.
it’s only negotiated, how it is accessed.
common is something like this http://server.domain.com/app/type/id=123 to retrieve object of type type with id=123
very intuitive, but no automatic validation of requests.
The main advantages of REST web services are:
Lightweight – not a lot of extra xml markup
Human Readable Results
Easy to build – no toolkits required
SOAP also has some advantages:
Easy to consume – sometimes
Rigid – type checking, adheres to a contract
Development tools