Javascript Interview Questions Flashcards
What is Javascript Scope?
In JavaScript there are two types of scope:Local scopeGlobal scopeLocal variables have Function scope: They can only be accessed from within the function.A global variable has global scope: All scripts and functions on a web page can access it.
What is 'this' in Javascript
It has different values depending on where it is used:In a method, this refers to the owner object.Alone, this refers to the global object.In a function, this refers to the global object.In a function, in strict mode, this is undefined.In any event, this refers to the element that received the eventMethods like call(), and apply() can refer this to any object.
What are callbacks?
A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
What method takes in an Array and outputs a new Array?
Takes in an Array, iterates over each array, then outputs a new Array?
What is iterate?
loop over or repeat over again
what does the push() do to an Array?
The push() method appends data to the end of an array.
what does the pop() do to an Array?
The pop() method "popsoff" the last element from the end of an array.
what does the shift() do to an Array?
The shift() method "shifts off" the first element from the beginning of an array.
What is MVC?
Model, View, ControllerSeparates application functionalityPromotes organized Programming
What is a closure?
A closure is a feature in JavaScript where an inner function has access to the outer (enclosing) function's variables â a scope chain.The closure has three scope chains:it has access to its own scope â variables defined between its curly bracketsit has access to the outer function's variablesit has access to the global variables
What is the "View" in MVC?
This layer which focuses o the client side. The goal of the View is, it represent the data on the UI screen using Template, Layouts etc. It should not have any knowledge of the Business Logic or Coupled to the backend (Model)
What is forEach()?
forEach() is the Array method that we can use to execute a function on each item in an array.
What is filter()?
The filter() method creates a new array with all elements that pass the test implemented by the provided function.
Object Literal Syntax?
A colon separates property name from value.A comma separates each name-value pair from the next.There should be no comma after the last name-value pair.
What is a reference?
the code that identifies where a piece of information is stored
What is a instance of a object?
Object is obtained when it has a life, means it has occupied some memory. Reference points to the Object. Instance is the copy of the Reference that points to object at a point of timeInstance is the actual object created at run time.
What is a variables name inside a object?
properties
What is an Expression?
Statements are made up of one or more expressions. An expression is any reference to a variable or value, or a set of variable(s) and value(s) combined with operators.
What is a block?
a block is defined by wrapping one or more statements inside a curly-brace pair { .. }
What you need?
You need operators to perform actions on values.You need values and types to perform different kinds of actions like math on numbers or output with strings.You need variables to store data (aka state) during your program's execution.You need conditionals like if statements to make decisions.You need loops to repeat tasks until a condition stops being true.You need functions to organize your code into logical and reusable chunks.
What are 6 primitive types?
string, number, boolean, symbol, null and undefined
when a variable in a local scope uses its value instead of avariable in a parent scope.So the local variables value is shadowing over the parents
Variable Shadowing
What is an Object?
A collection of Name Value Pairs
Global Means
Not inside a function
Global Execution Context
This is the default or base execution context. The code that is not inside any function is in the global execution context. It performs two things: it creates a global object which is a window object (in the case of browsers) and sets the value of this to equal to the global object. There can only be one global execution context in a program.
Global Object
A global object is an object that always exists in the global scope.