Monday, August 6, 2018

HCL Angular

1. Closure?
2. What is the benefit of closure?
3. this keyword based scenario?
4. Generator?
5. Generator is synchronous  or asynchronous?
And: Generator is synchronous, We can make it asynchronous using Promise or co library.

6 How to convert asynchronous generator to synchronous generator
Ans using yield.
7. If you have multiple objects and you want to right a function that is accesbile to all objects?
Ans
var a = {}; or a = new Object();
Object.prototype.print=(){
console.log('Hello World');
}

8. If we change something in prototype function will it change in all objects?

9. What are different type of decorator in angular?
Ans : There are four type of decorator in angular 
1. class Decorator ( @Component())
2. Function Decorator (@HostListener())
3. Property Decorator (@Input()..)
4. Constructor Decorator (@Inject())

10.What is @function (function decorator)?
Ans example is HostListener

11.If you have home page and in the home page multiple tab then how will you maintain the tab to displayed according to the role in angular way?
12. How will you manage state in redux?
13. Write a code , we receive user list from api. And need to display the list?
14. How the components communicate?
15. What is benefit of SPA?
16.

What will be return

return
0;

17. How will you implement inheritance in javascript?
Ans using prototype?
18. What is eval in javascript?
19. And why it is bad practice to use eval ?
Ans :  

1. It requires a compile and is therefore slow
2. Improper use of eval opens up your code for injection attacks

20. What will be print

var x=8;
var x = function  ()
{
console.log("fgf");
}


console.log(x);


Ans : 8;

21. What will be print

var x=8;
function x ()
{
console.log("fgf");
}


console.log(x);

Ans : 8;

22. What will be print

var x=8;
function x ()
{
console.log("fgf");
}


console.log(x());

Ans: Error 

Uncaught TypeError: x is not a function


No comments:

Followers

Link