JS MUST KNOW Flashcards
How many “Scopes” are there in JS?
In JavaScript, there can be following types of scopes:
Global Scope
Local Scope or Function Scope
Block Scope
`
What Do You Mean by “this“?
‘this’ is always a reference to an object
What is “Anonymous Function” in JS?
Anonymous Function is a function that does not have any name associated with it.
What Do You Know About BOM? (Browser Object Model)
The Browser Object Model (BOM) allows JavaScript to “talk to” the browser.
What is DOM?
When a web page is loaded, the browser creates a “Document Object Model” of the page.
The HTML DOM model is constructed as a tree of Objects.
How To Return a Character from a Specific Index?
charAt() string method
What are the Different Data Types in JS?
Primitive: String, Number, Boolean, Null, Undefined, Symbol, BigInt
Composite: Object and Array
What is “Prototype Property” in JS?
The prototype property allows you to add properties and methods to an object.
What is “Closure” in JS?
A closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.
Asynchronous Programming and Its Importance
Accommodates for the lag between when a function is called to when the value of that function is returned.
allows user to go about their business in an application, while processes run in the background.
Why Debugging is Required in JS?
scenarios where the script does not show any error in the browser.
the output is not similar to what is expected.
best option to find out the error is by debugging. This can be done by either console.log() or by using the debugger keyword.
What is “Function Hoisting” in JS?
Function hoisting is a JavaScript mechanism where function declarations are moved to the top of their scope before code execution. (Excludes function expressions)
Naming Conventions for Variables in JS
Don’t use reserves key words ie. Boolean
Don’t start the variable name with a number.
Variables are case sensitive.
What is a “Callback” in JS?
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 is “Global Scope”?
Global scope is the entire Javascript execution environment. Any variables assigned without an explicit scope automatically become global variables. The same is true for functions.
What is “Local Scope” in JS?
Variables declared within a JavaScript function are in local scope. They can only be accessed from within that function.