Umahluko phakathi kweMisebenzi yesiqhelo kunye neMisebenzi yeTolo kwiJavaScript

Ibhlog

Okunye ke umahluko wokudityaniswa. Umahluko ophambili yindlela eli gama eliphambili eliziphatha ngayo? Kumsebenzi wotolo, eli gama eliphambili lihlala lilingana kulo lonke ujikelezo lobomi bomsebenzi kwaye lihlala libotshelelwe kwixabiso lalokhu kulona lusondeleyo lomsebenzi womzali. Imisebenzi yeArrow ayinakuze ibe yimisebenzi yokwakha ukuze bangaze babizwe ngegama elingundoqo elitsha. Kwaye abanakuze baphinde kabini iiparameter ezinamagama njengomsebenzi oqhelekileyo ongasebenzisi imo engqongqo.



Nantsi imizekelo embalwa yekhowudi yokubonisa umahluko othile
// Regular function func1: function () { console.log(this); }, // Arrow function func2: () => { console.log(this); }

}

umntu.func1 ();// Biza umsebenzi oQhelekileyo
// Iziphumo: {igama: Jon, func1: [Umsebenzi: func1], func2: [Umsebenzi: func2]}



umntu.func2 ();// Biza umsebenzi weTolo
// Iziphumo: {igama: Bob}

Igama elingundoqo elitsha elinomsebenzi wotolo
this.name = 'Bob'; 

const person = {
name: Jon,



|_+_|

Ukuba ufuna ukubona inkcazo ebonakalayo kwiyantlukwano, uya kubona ividiyo engezantsi:

#arrow imisebenzi #javascript # imisebenzi eqhelekileyo #arrow imisebenzi vs eqhelekileyo imisebenzi # Umahluko phakathi kwemisebenzi kunye nemisebenzi yotolo

www.youtube.com

Umahluko phakathi kweMisebenzi yesiqhelo kunye neMisebenzi yeTolo kwiJavaScript

Okunye ke umahluko wokudityaniswa. Umahluko ophambili yindlela eli gama eliphambili eliziphatha ngayo? Kumsebenzi wotolo, eli gama eliphambili lihlala lilingana kulo lonke ujikelezo lobomi lomsebenzi kwaye lihlala libotshelelwe kwixabiso loku ...