Hoisting (tdz temporare deadzone)



Download 146,88 Kb.
Sana13.07.2022
Hajmi146,88 Kb.
#786750
Bog'liq
Object Reference


  1. Object Reference

  2. Data types

  3. Hoisting (TDZ - temporare deadzone)

  4. Code style

  5. Array methods

  6. Set, WeakSet

  7. Map, WeakMap

  8. This

  9. Constructor functions

  10. First class functions

  11. Higher order functions

  12. Closure

  13. Pure vs Impure functions

  14. Currying

  15. IIFE (immediately invoked function expression)

  16. Naming

  17. Class (getter, setter)

  18. Cookie

  19. Sinxron / asinxron

  20. Promise / callback



If src is set, the script content is ignored.
A single 

The example above can be split into two scripts to work:



Semicolons


This would also work:
alert('Hello')
alert('World')
This would also work:
alert('Hello')
alert('World')
Here, JavaScript interprets the line break as an “implicit” semicolon. This is called an “automatic semicolon insertion”.

const toggleElements = document.querySelectorAll('.toggle');


toggleElements.forEach(el => {
el.addEventListener('click', function() {
this.classList.toggle('active');
});
});

const toggleElements = document.querySelectorAll('.toggle');


toggleElements.forEach(el => {
el.addEventListener('click', () => {
this.classList.toggle('active'); // `this` refers to `Window`
// Error: Cannot read property 'toggle' of undefined
});
});

const toggleElements = document.querySelectorAll('.toggle');


toggleElements.forEach(el => {
el.addEventListener('click', (e) => {
e.currentTarget.classList.toggle('active'); // works correctly
});
});

For a long time, JavaScript evolved without compatibility issues. New features were added to the language while old functionality didn’t change.


That had the benefit of never breaking existing code. But the downside was that any mistake or an imperfect decision made by JavaScript’s creators got stuck in the language forever.
This was the case until 2009 when ECMAScript 5 (ES5) appeared. It added new features to the language and modified some of the existing ones. To keep the old code working, most such modifications are off by default. You need to explicitly enable them with a special directive: "use strict"

A variable is a “named storage” for data.

BigInt value is created by appending n to the end of an integer:


// the "n" at the end means it's a BigInt
const bigInt = 1234567890123456789012345678901234567890n;

Bitwise operators


Bitwise operators treat arguments as 32-bit integer numbers and work on the level of their binary representation.
These operators are not JavaScript-specific. They are supported in most programming languages.

The list of operators:



  • AND ( & )

  • OR ( | )

  • XOR ( ^ )

  • NOT ( ~ )

  • LEFT SHIFT ( << )

  • RIGHT SHIFT ( >> )

  • ZERO-FILL RIGHT SHIFT ( >>> )





let height = 0;


alert(height || 100); // 100
alert(height ?? 100); // 0

// Function Declaration
function sum(a, b) {
return a + b;
}
// Function Expression
let sum = function(a, b) {
return a + b;
};



Download 146,88 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish