Home Java Questions from interviews and conversations with Junas

Questions from interviews and conversations with Junas

by admin

My experience is that interview questions vary dramatically from interview to interview.I’ve compiled all of the questions I’ve been asked at job interviews for two years, as well as the questions I’ve been asked by jounas at work, to show you.

This article will be of interest to those who want to get a job.It will also help those who are not confident in their knowledge and want to test themselves.Experienced developers will probably finda couple of interesting things for themselves, while newbies will get a lot of information to think about.Let’s get started.

Basic Javascript

Which will output the following code snippet :

const symbol = Symbol('foo');const object = {[symbol]: 1};console.log(object[Symbol('foo')]);
Show reply

This code will output undefined as the symbol is a unique identifier.You can check :

console.log(Symbol('f') === Symbol('f'));> false

You can read more about the symbols here

Which will output the following code snippet :

const m = 10000;new Intl.NumberFormat('de-DE', {style: 'currency', currency: 'EUR'}).format(m);
Show reply

This code will output '10.000, 00€'

Intl – is a number constructor which depends on the language

Read more at MDN

Which will output the following fragment :

const [num, str] = [10, 'str'];console.log(Number.isNaN(str), Number.isNaN(num), isNaN(num), isNaN(str));
Show reply

This code will output false, false, false, true

More about the differences Number.isNaN() and isNaN() here

What this code snippet will output :

console.log(JSON.stringify({x: 5, y: 7}, ['x', 8]));
Show reply

This code will output {"x": 5}

Read more about JSON.stringify() you can see here

Continued :

console.log(typeof('1' + 1));
Show reply

The interpreter will output 'string'

Any expression added to a stringwhere the string is the first operand is converted to a string. The expression '11' is of type string

Continued questions about type casting :

var str = "1";str = +!str;console.log(typeof str);
Show reply

This code will output 'number'

String with operator not ( ! ) turns into false (any nonempty string is converted to true ). Unary plus turns any value into a number primitive. false converted to numbers is zero. The expression 0 is a number

Another question about type conversions :

console.log(+`3`- true+ '1');
Show reply

This code will output '21'

Unary plus turns the string `3` into a number. true is converted to one =gt when calculated with a number; 3 - 1 = 22 + '1' = '21'

Next question :

What is the length of the array?

let arr = [1, 2, 3, 4, 5];deletearr[0];

The length of the array will be 5, because instead of the first element it will just be a void, but the length will not change.

More about delete here

Which of these methods changes the array rather than returning a new :

  • map

  • reduce

  • splice

  • slice

  • find

  • filter

Answer

Of all the methods of the prototype Array only splice() Edits the array itself, not creates a copy of the array.

What will be the output of this program :

const config = {react: true, node: false, angular: true, javascript: true}const techStack = ['javascript', 'angular', 'react'];console.log(config.techStack[1]);
Show reply

TypeError – the answer to this question.

What this code will print out :

console.log([] === []);
View reply

This code will output false

In this case JS is comparing two pointers, not their contents.
You can see in more detail here

React

What is the equivalent of this code

React.createElement('div', { style: { color: 'red' } }, 'title="block"')

Show reply
<div style="color: red;"> title="block"</div>

Tell me the sequence of methods that occurs when a component is mounted?

Reply
  1. constructor()

  2. static getDerivedStateFromProps()

  3. render()

  4. componentDidMount()

Tell me the sequence of methods that occurs when a component is updated?

Show reply
  1. getDerivedStateFromProps()

  2. shouldComponentUpdate()

  3. render()

  4. getSnapshotBeforeUpdate()

  5. componentDidUpdate()

How to deploy spread operator to make all elements from the object go to props?

Reply
const opts = {foo: 'a', bar: 'b'};// .....<Component {...opts}/>

If you were interested in reading about the exact questions I answered in interviews, you can subscribe to my tvgram channel, there is a lot of stuff like this there

Some questions seem like agony, however, employers are employers. I would naturally ask questions directly related to the job rather than racing through the knowledge nooks and crannies of the language.. Thank you for finishing this article, I hope it was interesting and that you had a little bit of a headache, as I did once in job interviews. Have a great day and a productive week!

You may also like