javascript interview questions for experienced code example

Example 1: javascript interview questions

// Collection of data in key-value pairs
JAVASCRIPT OBJECTS


var obj1 = {
   x:  43,
   y:  "Hello world!",
   z: function(){
      return this.x;
   }
}
      
// Collection of data as an ordered list
      
var array1 = [5, "Hello", true, 4.1];

Example 2: var x=21; var myFunction = function(){ console.log(x); var x= 20; }; myFunction();

var x=21;
var myFunction = function(){
console.log(x);
var x= 20;
};
myFuntion();

Example 3: javascript interview questions

class Person {
   constructor(name) {
      this.name = name;
   }
}

var object = new Person("Sudheer");