Top JavaScript interview questions
******************************In progress
- JavaScript is the world's most popular programming language used for web development. It can be used to update HTML and CSS
- Nowadays, JavaScript is getting used in many other areas e.g. server-side development, mobile app development etc.
Primitive | Non-primitive |
---|---|
Boolean, NULL, undefined, BigInt, String, Number, Symbol | Object |
a) Object Literals: A comma-separated set of name and value pairs that is wrapped inside curly braces.
var person = { name: 'Surbhi', age: 25, occupation: 'Software Engineer' }
b) Object.create method: TCreates a new object, by using an existing object as the prototype of the newly created object.
const person = { name: 'Surbhi', age: 25, occupation: 'Software Engineer' } var info = Object.create(person); console.log(info.name); // output - Surbhi Here "person" is an existing object which is passed as a prototype to the newly created object "info"
const person = new Person();
class Person { constructor(name) { this.name = name; } } let person = new Person('Surbhi'); console.log(person.name); //output - Surbhi
- == : While comparing two operands, checks for only value
- === : While comparing two operands, checks for value as well as data type
- JavaScript is Single-threaded
- Yes, using Spread Operators
const arr1 = [1,2,3,4]; const arr2 = [5,6]; const arr3 = [...arr1, ...arr2] console.log(arr3) //output - [1,2,3,4,5,6]
******************************In progress