Interview Questions Flashcards
Explain the differences between var, const and let.
The weakest signal available in ES6 is var.
‘Let’ signals that a variable might be reassigned, and can be used for example in loops, for counting.
‘Const’ signals that that identifier will not be reassigned.
What is the difference between == and ===?
The == operator compares two values, without taking into account their types. === compares the values, but also makes their types into account. So 3==’3’ evaluates to True, but 3===’3’ evaluates to False.
What is the difference between textContent and innerHTML?
textContent is a concatenation of the text content of a node and its descendant. It is the fastest of the two.
innerHTML returns the HTML. It parses the text into HTML, which makes it slower.
What is a node?
TBD
What is the DOM?
DOM stands for the Documentation Object Models, and it is a World Wide Web Consortium standard.It defines a standard for accessing documents, and it can be used to access and change the content of the HTML.
What are the JavaScript data types?
There are seven data types: Boolean, Null, Undefined, Number, String, Symbol, Object. The first six are primitives, meaning data types that aren’t objects and do not have any methods.
What are the pop-up boxes types available in JavaScript?
There are 3 pop up boxes: Alert, Confirm and Prompt.
What do the break and the continue statements do?
The break statement is used to exit a current loop. On the other hand, the continue statement continues with the next announcement in the loop.
What is negative infinity in JavaScript?
The result of a negative number divided by 0.
Give us an example of an object declaration.
Var person = {
fullName: ‘Andrew Smith’,
Age: 34,
Email: ‘andrew.smith@gmail.com’
}
Explain the difference between null, undefined or undeclared variables.
Undefined variables have been declared, but no value exists for them. Null is a value of variables, as well as a type of object. Undeclared variables are those declared without the var, const or let keyword.
How do objects, classes, inheritance work in JavaScript?
ES6, introduced classes. A class is a type of function, but instead of using the keyword function to initiate it, we use the keyword class, and the properties are assigned (initialized) inside a constructor() method.
class Car { constructor(brand) { this.carname = brand; } }
An object is an instance of the class. mycar = new Car("Ford");
Inheritance is a mechanism in which one (child) class/object acquires all the properties and behaviors of another (parent) class/object
Classical Inheritance vs Prototypal Inheritance?
Javascript is not a class-based language. JavaScript works on prototype chain.
Classical inheritance creates a copy of the behavior from parent class/object into the child. And after that parent and child class are separate entity.
Prototypal Inheritance (also called called Behavior Delegation Pattern), In JavaScript, when we create the object it does not copy the properties or behavior, it creates a link. (a prototype chain)
Syntax keyword for creating instances of subclass?
“new”
What is the syntax to create a method?
class Car { constructor(brand) { this.carname = brand; } present() { return "I have a " + this.carname; } }
mycar = new Car("Ford"); document.getElementById("demo").innerHTML = mycar.present();
What are static methods?
Static methods are defined on the class itself, not the prototype. So you can only call it on the class.
How do you create a class inheritance?
To create a class inheritance, use the extends keyword.
A class created with a class inheritance inherits all the methods from another class:
class Car { constructor(brand) { this.carname = brand; } present() { return 'I have a ' + this.carname; } }
class Model extends Car { constructor(brand, mod) { super(brand); this.model = mod; } show() { return this.present() + ', it is a ' + this.model; } }
What is hoisting?
The default behavior of JavaScript declarations, moving a function declaration to the top. So for declarations, like functions, you will NOT get an error when you try to use it before it is declared.
However class declarations are not hoisted. That means that you must declare a class before you can use it.
What is strict mode?
In “strict mode” you will get an error if you use a variable without declaring it:
class Car { constructor(brand) { i = 0; this.carname = brand; } } var mycar = new Car("Ford");
What are some Javascript frameworks?
React, Angular, Vue, opeFramework, Cinder
What is WebGL?
WebGL: is the Javascript API that allows you to create 3D graphics in the browser.