Рет қаралды 25,703
Նկարագրություն
------------------------------
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 դասընթաց: • Ծրագրավորման Արվեստ | ...
Ֆեյսբուքյան էջ: / roubenmeschian
Ֆեյսբուքյան խումբ: / 1647352038759065
Կոդերի խմբագիր: roubenmeschian.com/editor/