Skip to content

Latest commit

 

History

History
60 lines (52 loc) · 3.5 KB

javascript.md

File metadata and controls

60 lines (52 loc) · 3.5 KB

#JavaScript

What are possible variable scopes?

  • Local scope
  • Global scope
Relative links:

What is bind? call & apply?

call()/apply() to invoke the function immediately. bind() returns a bound function that, when executed later, will have the correct context ("this") for calling the original function. So bind() can be used when the function needs to be called later in certain events when it's useful.

Relative links:

What is losing of context in js?

this is set primarily by how the function is called, not where it's defined.

Relative links:

Is Javascript single threaded?

Javascript is a single threaded language. This means it has one call stack and one memory heap. As expected, it executes code in order and must finish executing a piece code before moving onto the next.

Relative links:

What is closure in js?

A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain. The closure has three scope chains: it has access to its own scope (variables defined between its curly brackets), it has access to the outer function’s variables, and it has access to the global variables.

Relative links:

How to check if element exists in html?

here's an easy way to do it with jQuery:

if ($('#elementId').length > 0) {
  // exists.
}

And if you can't use 3rd-party libraries, just stick to base JavaScript:

var element =  document.getElementById('elementId');
if (typeof(element) != 'undefined' && element != null)
{
  // exists.
}
Relative links:

2 functions with the same name but with different number of parameters. Can be the issues in this case?

it is not possible to overload functions in Javascript

Relative links:

Home Page