JavaScript has been the most used programming language for many years now, yet people continue to struggle to grasp it. This article sets out to discuss some of the most frequently asked questions in JavaScript.

Question

What is the value of **x **& y ?

const fn = (a, ...numbers, x, y) => {
    console.log(x, y)
};

Solution

SyntaxError: Rest parameter must be last formal parameter

Rest parameters must always be the last argument to a function.


Question

Guess the output of the following code:

var hero = {
    _name: 'John Doe',
    getSecretIdentity: function (){
        return this._name;
    }
};
var stoleSecretIdentity = hero.getSecretIdentity;
console.log(stoleSecretIdentity());
console.log(hero.getSecretIdentity());

#javascript #interview-questions

JavaScript Interview-Questions: Functions
14.80 GEEK