javascript this = that
// In web browsers, the window object is also the global object:
console.log(this === window); // true
a = 37;
console.log(window.a); // 37
this.b = "MDN";
console.log(window.b) // "MDN"
console.log(b) // "MDN"
var colours = ['red', 'green', 'blue'];
document.getElementById('element').addEventListener('click', function() {
// this is a reference to the element clicked on
var that = this;
colours.forEach(function() {
// this is undefined
// that is a reference to the element clicked on
});
});
Also in JavaScript:
- javascript insertBefore
- c# get json object from the immediate window?
- jsx full form
- how to submit a form in js
- check if date is today js
- What is the correct JavaScript syntax for opening a new window called "w2" ?
- constructor react
- react native preload local images
- get selected text js
- how to output to console java
- react enzyme
- java script functions
- angular 7 folder structure best practices
- js redirect to url
- js null is object typeof
- launch.json vscode electron
- create a html table dynamically using javascript
- how to change the font family using jquery
- angular bootstrap
- hook access loopback
- vanilla javascript jwt authentication laravel
- how to do basic authentication with fetch api
- devtools failed to load sourcemap when debugging react native
- lodash map