Javascript – this
Նկարագրություն
——————————
this-ի օգնությամբ կարելի է դիմել այն կոնտեքստին, որում ֆունկցիան է իրականացվում
Կոդի օրինակներ
——————————-
function func(a) {
alert(this);
alert(a);
}
const obj = {
func: func
};
obj.func(5); // this = obj
func(5); // this = global object (window in the browser) OR undefined in script mode
func.apply(obj, [5]); // this = obj
func.call(obj, 5); // this = obj
const boundFunc = func.bind(obj);
boundFunc(5); // this = obj
new func(5); // this = {}
Հղումներ
—————-
Javascript դասընթաց: https://youtube.com/playlist?list=PLkVo56yGU5Pqld7f3jtoE-g_755aPT0NV
Ֆեյսբուքյան էջ: https://www.facebook.com/roubenmeschian
Ֆեյսբուքյան խումբ: https://www.facebook.com/groups/1647352038759065
Կոդերի խմբագիր: https://roubenmeschian.com/editor/
Comments are closed.