js - all
js - all
JavaScript:
1. Event loop,
2. call,apply,bind, -> bind*,
3. closers & disadvantages of using closures
4. hoisting,
5. .this,
6. arrow function,
7. spread operator, set, rest, reduce
8. array helper function => filter, map, foreach -> diff & return
9. Inheritance -> Class & Prototypal Inheritance,
10. Class & function, -> es6
11. import & export VS required,
12. function currying,
13. promises VS async await -> difference
14. Callback
15. pure function,
16. event bubbling,
17. event target,
18. deep copy & shall copy,
19. DE structuring
20. IIF -> self invoking
21. polyfill for .bind
22. design pattern *
23. seo
24. memory leaks
25. HOC
26. Event listener
27. Temp var with eg
Common:
Authentication implementation, *
Performance testing, *
Security,
Application Performance improvement
webpack
package json -> dependence
best way to iterate large json value eg:pagination, lazy loading *
sso
shared component
how we go with component structure .. eg: from scratch …
cookies, session, local storage
JavaScript Coding:
1. sum of numbers
o eg: const a = [10,30,40,10,60] sum=50.
o With single iteration
2. Sum of number
a. Const a = [10,20,30,[40,50],70] output = total
3. Input = “ababbccdd” output=“2a3b2c2d”
4. Array find largest and second largest eg: const a = [10,30,40,60,70,90,40];
5. Input=5, output = [1,1,2,3,5,8]
6. Find prime number
7. swap -> temp
8. for(let i=0;i<10;i++){ setTimeout(() => {console.log(i);},100);}
9.
logoutput() {console.log('button')}
11.
const Avengers = [
fname: "tony",
lname: "stark",
age: 30,
gender: "M",
},
fname: "natasha",
lname: "romonov",
age: 23,
gender: "M",
];
function Select(string,arr){
for(let i=0;i<input.length;i++){
obj[currentVal] = val[currentVal];
arrResult.push(obj);
return arrResult;
console.log(list2);
TypeScript is a superset of JavaScript that gives you advantages like: Optional static
typing (the key here is optional) Type Inference,
let n1 = 0, n2 = 1, nextTerm;
let number = 10;
let arr = [];
for (let i = 0; i < number; i++) {
arr.push(n1);
nextTerm = n1 + n2;
n1 = n2;
n2 = nextTerm;
}
console.log(arr);
or
[a,b] = [b,a]
React JS:
HTML:
Div hight
Css:
flex-direction
flex-wrap
flex-flow
justify-content
align-items
align-content
Testcase:
describe('CrashRiskGridComponent', () => {
let component: CrashRiskGridComponent;
let fixture: ComponentFixture<CrashRiskGridComponent>;
let crashRiskGridService: CrashPreventionService;
beforeEach(() => {
const mockStateAdapter = createSpyFromClass(StateAdapter, {
TestBed.configureTestingModule({
imports: [
CrashRiskGridModule,
HttpClientTestingModule,
RouterTestingModule,
OktaAuthServiceTestModule,
],
providers: [
{ provide: 'ENVIRONMENT', useValue: {} },
provideMockStore({
selectors: [
{
selector: userStateSelectors.selectUserState,
crashRiskGridService = TestBed.inject(CrashPreventionService);
fixture = TestBed.createComponent(CrashRiskGridComponent);
component = fixture.componentInstance;
fixture.detectChanges();
jest
.spyOn(crashRiskGridService, 'findRiskDevices')
.mockReturnValue(of(RiskScenarios[4].scenarios.GET[0].response.body));
JS:
2. rest vs spread
3.setTimeout()
4.
https://www.programiz.com/javascript/setInterval
console.log(chars.filter((chr,index)=>chars.indexOf(chr)===index)
var data = [{
"name": "Peter",
"age": 30,
}, {
"name": "Steve",
"age": 55,
}, {
"name": "Steve",
"age": 55,
}];
//console.log(JSON.stringify(data));
if(!distinctList.length || ((JSON.stringify(distinctList)).indexOf(JSON.stringify(obj))==-1))
distinctList.push(obj);
}
console.log(distinctList);
let largest=0;
let second = 0;
for(let i=0;i<=arr.length;i++){
if(arr[i]>largest){
second = largest;
largest = arr[i];
}else if(arr[i] > second && arr[i] != largest ){
second = arr[i];
}
}
console.log(second);