javascript questions interview code example

Example 1: javascript interview questions

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

var object = new Person("Sudheer");

Example 2: 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 3: asking questions javascript in console

var readline = require('readline');

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.question("What do you think of node.js? ", function(answer) {
  console.log("Thank you for your valuable feedback:", answer);

  rl.close();
});