Szybki trening JavaScript

Obiekty

Rozszerzenia obiekt贸w

                
                    let a = {

                        x: 1
                    };
                    
                    let b = {
                    
                        y : 2
                    };
                    
                    Object.setPrototypeOf(a,b)
                    console.log(a.y);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Rozszerzenia obiekt贸w

                
                    let a = {

                        x: 1
                    };
                    
                    let b = {
                    
                        y : 2
                    };
                    
                    Object.setPrototypeOf(a,b)
                    console.log(a.y);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        2
                    
                

Rozszerzenia obiekt贸w

                
                    let a = {a: 1}, b = {b:2};

                    let target = {};
                    Object.assign(target,a,b);
                    
                    console.log(target);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Rozszerzenia obiekt贸w 2

                
                    let a = {a: 1}, b = {b:2};

                    let target = {};
                    Object.assign(target,a,b);
                    
                    console.log(target);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        {a: 1, b: 2}
                    
                

Rozszerzenia obiekt贸w 4

                
                    let a = {a: 1}, b = {a:3,b:2};

                    let target = {};
                    Object.assign(target,a,b);
                    
                    console.log(target);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Rozszerzenia obiekt贸w 4

                
                    let a = {a: 1}, b = {a:3,b:2};

                    let target = {};
                    Object.assign(target,a,b);
                    
                    console.log(target);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        {a: 3, b: 2}
                    
                

Rozszerzenia obiekt贸w 5

                
                    let a = {a: 1}, b = {a:3,b:2};

                    Object.defineProperty(b,'c', {
                        value: 10,
                        enumerable : false
                    });
                    
                    let target = {};
                    Object.assign(target,a,b);
                    console.log(target);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Rozszerzenia obiekt贸w 5

                
                    let a = {a: 1}, b = {a:3,b:2};

                    Object.defineProperty(b,'c', {
                        value: 10,
                        enumerable : false
                    });
                    
                    let target = {};
                    Object.assign(target,a,b);
                    console.log(target);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        {a: 3, b: 2}
                    
                

Rozszerzenia obiekt贸w 6

                
                    let a = {a: 1}, b = {a:3,b:2};

                    Object.defineProperty(b,'c', {
                        value: 10,
                        enumerable : true
                    });
                    
                    let target = {};
                    Object.assign(target,a,b);
                    console.log(target);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        {a: 3, b: 2, c: 10}
                    
                

Rozszerzenia obiekt贸w 6

                
                    let a = {a: 1}, b = {a:3,b:2};

                    Object.defineProperty(b,'c', {
                        value: 10,
                        enumerable : true
                    });
                    
                    let target = {};
                    Object.assign(target,a,b);
                    console.log(target);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        {a: 3, b: 2, c: 10}
                    
                

Rozszerzenia obiekt贸w 7

                
                    let a = {a: 1}, b = {a:3,b:2};
                    let c = {c:50};
                    
                    Object.setPrototypeOf(b,c);
                    
                    let target = {};
                    Object.assign(target,a,b);
                    console.log(target);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Rozszerzenia obiekt贸w 7

                
                    let a = {a: 1}, b = {a:3,b:2};
                    let c = {c:50};
                    
                    Object.setPrototypeOf(b,c);
                    
                    let target = {};
                    Object.assign(target,a,b);
                    console.log(target);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        {a: 3, b: 2}
                    
                

Rozszerzenia obiekt贸w 9

                
                    let amount = NaN;

                    console.log(amount === amount);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Rozszerzenia obiekt贸w 9

                
                    let amount = NaN;

                    console.log(amount === amount);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        false
                    
                

Rozszerzenia obiekt贸w 9

                
                    let amount = NaN;

                    let check = Object.is(amount,amount);
                    console.log(check);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Rozszerzenia obiekt贸w 9

                
                    let amount = NaN;

                    let check = Object.is(amount,amount);
                    console.log(check);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        true
                    
                

Rozszerzenia obiekt贸w 10

                
                    let a1 = 0;
                    let a2 = -0;
                    
                    console.log(a1 === a2 );
                
            

馃挕 Co pojawi si臋 w konsoli ?

Rozszerzenia obiekt贸w 10

                
                    let a1 = 0;
                    let a2 = -0;
                    
                    console.log(a1 === a2 );
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        true
                    
                

Rozszerzenia obiekt贸w 11

                
                    let a1 = 0;
                    let a2 = -0;
                    
                    let check = Object.is(a1,a2);
                    console.log(check);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Rozszerzenia obiekt贸w 11

                
                    let a1 = 0;
                    let a2 = -0;
                    
                    let check = Object.is(a1,a2);
                    console.log(check);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        false
                    
                

Rozszerzenia obiekt贸w 11

                
                    let blog = {
                        title : 'Blog Name',
                        [Symbol.for('Szybki trening JS')] : 'content 1',
                        [Symbol.for('TDD z C#')] : 'content 2',
                    };
                    
                    console.log(Object.getOwnPropertySymbols(blog));
                
            

馃挕 Co pojawi si臋 w konsoli ?

Rozszerzenia obiekt贸w 11

                
                    let blog = {
                        title : 'Blog Name',
                        [Symbol.for('Szybki trening JS')] : 'content 1',
                        [Symbol.for('TDD z C#')] : 'content 2',
                    };
                    
                    console.log(Object.getOwnPropertySymbols(blog));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        [Symbol(Szybki trening JS), Symbol(TDD z C#)]
                    
                

Rozszerzenia obiekt贸w 11

                
                    const map = new Map
                    ([['name','K'],['desc','A']]);

                    const obj = Object.fromEntries(map);

                    console.log(obj);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Rozszerzenia obiekt贸w 11

                
                    const map = new Map
                    ([['name','K'],['desc','A']]);

                    const obj = Object.fromEntries(map);

                    console.log(obj);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        {name: "K", desc: "A"}
                    
                

ES10 : Rozszerzenia obiekt贸w 11

                
                    var getGlobal = function() {

                        if (typeof self !== undefined) {return self;}
                        if (typeof window !== undefined) {return window;}
                        if (typeof global !== undefined) {return global;}

                        throw new Error('unable to locate global object')
                    };

                    var global = getGlobal();
                    console.log(global);
                
            

馃挕 Co pojawi si臋 w konsoli ?

ES10 : Rozszerzenia obiekt贸w 11

                
                    var getGlobal = function() {

                        if (typeof self !== undefined) {return self;}
                        if (typeof window !== undefined) {return window;}
                        if (typeof global !== undefined) {return global;}

                        throw new Error('unable to locate global object')
                    };

                    var global = getGlobal();
                    console.log(global);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        Window聽{parent: Window, opener: null, top: Window, length: 4, frames: Window,聽鈥
                    
                

ES10 : Rozszerzenia obiekt贸w 12

                

                    console.log(globalThis);
                
            

馃挕 Co pojawi si臋 w konsoli ?

ES10 : Rozszerzenia obiekt贸w 12

                

                    console.log(globalThis);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        Window聽{parent: Window, opener: null, top: Window, length: 4, frames: Window,聽鈥
                    
                

ES10 : Rozszerzenia obiekt贸w 12

                

                    console.log(globalThis);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        Window聽{parent: Window, opener: null, top: Window, length: 4, frames: Window,聽鈥
                    
                

String

String : 1

                
                    let movieTitle = 'Avenger: EndGame';

                    let check = movieTitle.startsWith('Avengers');
                    console.log(check);
                
            

馃挕 Co pojawi si臋 w konsoli ?

String : 1

                
                    let movieTitle = 'Avenger: EndGame';

                    let check = movieTitle.startsWith('Avengers');
                    console.log(check);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        true
                    
                

String : 2

                
                    let movieTitle = 'Avenger: EndGame';

                    let check = movieTitle.includes('en');
                    console.log(check);
                
            

馃挕 Co pojawi si臋 w konsoli ?

String : 2

                
                    let movieTitle = 'Avenger: EndGame';

                    let check = movieTitle.includes('en');
                    console.log(check);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        true
                    
                

String : 3

                
                    let a1 = "Lubie biega膰 \u{1F3C3}"
                    let a2 = "Lubie p艂ywa膰 \u{1F3CA}"
                    let a3 = "Lubie wygrywa膰 \u{1F3C6}"
                    
                    console.log(a1);
                    console.log(a2);
                    console.log(a3);
                
            

馃挕 Co pojawi si臋 w konsoli ?

String : 3

                
                    let a1 = "Lubie biega膰 \u{1F3C3}"
                    let a2 = "Lubie p艂ywa膰 \u{1F3CA}"
                    let a3 = "Lubie wygrywa膰 \u{1F3C6}"
                    
                    console.log(a1);
                    console.log(a2);
                    console.log(a3);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        Lubie biega膰 馃弮,Lubie p艂ywa膰 馃強,Lubie wygrywa膰 馃弳
                    
                

String : 4

                
                    let a1 = "\u{1F3C3}"
                    let a2 = "\u{1F3CA}"
                    let a3 = "\u{1F3C6}"
                    
                    console.log(a1.length);
                    console.log(a2.length);
                    console.log(a3.length);
                
            

馃挕 Co pojawi si臋 w konsoli ?

String : 4

                
                    let a1 = "\u{1F3C3}"
                    let a2 = "\u{1F3CA}"
                    let a3 = "\u{1F3C6}"
                    
                    console.log(a1.length);
                    console.log(a2.length);
                    console.log(a3.length);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        2,2,2
                    
                

String : 5

                
                    let a = "\u{1F3C3}\u{1F3CA}\u{1F3C6}";

                    console.log(a);
                    console.log(Array.from(a).length);
                
            

馃挕 Co pojawi si臋 w konsoli ?

String : 5

                
                    let a = "\u{1F3C3}\u{1F3CA}\u{1F3C6}";

                    console.log(a);
                    console.log(Array.from(a).length);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        馃弮馃強馃弳,3
                    
                

String : 6

                
                    let a = "przez \u0301n";

                    console.log(a + " " + a.length);
                
            

馃挕 Co pojawi si臋 w konsoli ?

String : 6

                
                    let a = "przez \u0301n";

                    console.log(a + " " + a.length);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        przez 虂n 8
                    
                

String : 7

                
                    console.log(String.fromCodePoint(0x1f3ca));
                
            

馃挕 Co pojawi si臋 w konsoli ?

String : 7

                
                    console.log(String.fromCodePoint(0x1f3ca));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        馃強
                    
                

String : 8

                
                    let a = 'Przez';
                    let output = String.raw `${a} \u{1f3c4}\n`;
                    console.log(output);
                
            

馃挕 Co pojawi si臋 w konsoli ?

String : 8

                
                    let a = 'Przez';
                    let output = String.raw `${a} \u{1f3c4}\n`;
                    console.log(output);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        Przez \u{1f3c4}\n
                    
                

String : 8

                
                    let a = '\u{1f30a}\u{1f3c4}\u{1f30a}';
                    console.log(a.repeat(4));
                
            

馃挕 Co pojawi si臋 w konsoli ?

String : 8

                
                    let a = '\u{1f30a}\u{1f3c4}\u{1f30a}';
                    console.log(a.repeat(4));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        馃寠馃弰馃寠馃寠馃弰馃寠馃寠馃弰馃寠馃寠馃弰馃寠
                    
                

String : 10

                
                    var str = '                  cez   ';
                    console.log(str.length);

                    str = str.trimStart();
                    console.log(str.length);
                    str = str.trimEnd();
                    console.log(str.length);
                
            

馃挕 Co pojawi si臋 w konsoli ?

String : 10

                
                    var str = '                  cez   ';
                    console.log(str.length);

                    str = str.trimStart();
                    console.log(str.length);
                    str = str.trimEnd();
                    console.log(str.length);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        24,6,3
                    
                

Number

Number 1

                
                    console.log(Number.parseInt === parseInt);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Number 1

                
                    console.log(Number.parseInt === parseInt);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        true
                    
                

Number 2

                
                    console.log(Number.parseFloat === parseFloat );
                
            

馃挕 Co pojawi si臋 w konsoli ?

Number 2

                
                    console.log(Number.parseFloat === parseFloat );
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        true
                    
                

Number 3

                
                    let s = 'NaN'
                    console.log(isNaN(s));
                    console.log(Number.isNaN(s));
                
            

馃挕 Co pojawi si臋 w konsoli ?

Number 3

                
                    let s = 'NaN'
                    console.log(isNaN(s));
                    console.log(Number.isNaN(s));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        true,false
                    
                

Number 4

                
                    let nan = NaN;
                    let infinity = Infinity;
                    let un = undefined;
                    let just = 3;
                    
                    console.log(Number.isInteger(nan));
                    console.log(Number.isInteger(infinity));
                    console.log(Number.isInteger(un));
                    console.log(Number.isInteger(just));
                
            

馃挕 Co pojawi si臋 w konsoli ?

Number 4

                
                    let nan = NaN;
                    let infinity = Infinity;
                    let un = undefined;
                    let just = 3;
                    
                    console.log(Number.isInteger(nan));
                    console.log(Number.isInteger(infinity));
                    console.log(Number.isInteger(un));
                    console.log(Number.isInteger(just));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        false,false,false,true
                    
                

Number 4

                
                    let s = '1';
                    console.log(isFinite(s));
                    console.log(Number.isFinite(s));
                
            

馃挕 Co pojawi si臋 w konsoli ?

Number 4

                
                    let s = '1';
                    console.log(isFinite(s));
                    console.log(Number.isFinite(s));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                   true,false
                    
                

Number 6

                
                    let a = Math.pow(2,53) - 1;
                    console.log(Number.isSafeInteger(a));
                    a = Math.pow(2,53);
                    console.log(Number.isSafeInteger(a));
                
            

馃挕 Co pojawi si臋 w konsoli ?

Number 6

                
                    let a = Math.pow(2,53) - 1;
                    console.log(Number.isSafeInteger(a));
                    a = Math.pow(2,53);
                    console.log(Number.isSafeInteger(a));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        true,false
                    
                

Number 7

                
                    console.log(Number.EPSILON);
                    console.log(Number.MAX_SAFE_INTEGER);
                    console.log(Number.MIN_SAFE_INTEGER);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Number 7

                
                    console.log(Number.EPSILON);
                    console.log(Number.MAX_SAFE_INTEGER);
                    console.log(Number.MIN_SAFE_INTEGER);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        2.220446049250313e-16 , 9007199254740991 , -9007199254740991
                    
                

RegEXP

RegEXP 1

                
                    let pattern = /\u{1F3C3}/

                    console.log(pattern.test('馃弮'));
                
            

馃挕 Co pojawi si臋 w konsoli ?

RegEXP 1

                
                    let pattern = /\u{1F3C3}/

                    console.log(pattern.test('馃弮'));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        false
                    
                

RegEXP 1

                
                    let pattern = /\u{1F3C3}/

                    console.log(pattern.test('馃弮'));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        false
                    
                

RegEXP 2

                
                    let pattern = /\u{1F3C3}/u

                    console.log(pattern.test('馃弮'));
                
            

馃挕 Co pojawi si臋 w konsoli ?

RegEXP 2

                
                    let pattern = /\u{1F3C3}/u

                    console.log(pattern.test('馃弮'));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        true
                    
                

RegEXP 3

                
                    let pattern = /^.Bieg/

                    console.log(pattern.test('馃弮Bieg'));
                
            

馃挕 Co pojawi si臋 w konsoli ?

RegEXP 3

                
                    let pattern = /^.Bieg/

                    console.log(pattern.test('馃弮Bieg'));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        false
                    
                

RegEXP 4

                
                    let pattern = /^.Bieg/u

                    console.log(pattern.test('馃弮Bieg'));
                
            

馃挕 Co pojawi si臋 w konsoli ?

RegEXP 4

                
                    let pattern = /^.Bieg/u

                    console.log(pattern.test('馃弮Bieg'));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        true
                    
                

RegEXP 5

                
                    let pattern = /1000/y
                    console.log(pattern.lastIndex);
                    console.log(pattern.test(8009001000));
                
            

馃挕 Co pojawi si臋 w konsoli ?

RegEXP 5

                
                    let pattern = /1000/y
                    console.log(pattern.lastIndex);
                    console.log(pattern.test(8009001000));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        false
                    
                

RegEXP 6

                
                    let pattern = /1000/y
                    pattern.lastIndex = 6;
                    console.log(pattern.test(8009001000));
                
            

馃挕 Co pojawi si臋 w konsoli ?

RegEXP 6

                
                    let pattern = /1000/y
                    pattern.lastIndex = 6;
                    console.log(pattern.test(8009001000));
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        true
                    
                

RegEXP 7

                
                    let pattern = /1000/yg

                    console.log(pattern.flags);
                
            

馃挕 Co pojawi si臋 w konsoli ?

RegEXP 7

                
                    let pattern = /1000/yg

                    console.log(pattern.flags);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        gy
                    
                

RegEXP 8

                
                    var regex = /cz(a)(ry(\d?\d?))/g;
                    var str = 'czary10czary20czary30';
                    
                    str.match(regex ); 
                
            

馃挕 Co pojawi si臋 w konsoli ?

RegEXP 8

                
                    var regex = /cz(a)(ry(\d?\d?))/g;
                    var str = 'czary10czary20czary30';
                    
                    str.match(regex ); 
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        ["czary10", "czary20", "czary30"]
                    
                

RegEXP 9

                
                    var regex = /cz(a)(ry(\d?\d?))/g;
                    var str = 'czary10czary20czary30';
                    
                    let array = [...str.matchAll(regex )]; 
                    console.log(array);
                
            

馃挕 Co pojawi si臋 w konsoli ?

RegEXP 9

                
                    var regex = /cz(a)(ry(\d?\d?))/g;
                    var str = 'czary10czary20czary30';
                    
                    let array = [...str.matchAll(regex )]; 
                    console.log(array);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        ["czary10", "a", "ry10", "10", index: 0, input: "czary10czary20czary30"
                    
                

RegEXP 10

                
                    const eventDate = /(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})/;

                    const matchedObject = eventDate.exec('2020-06-30');
                    console.log(matchedObject.groups.year);
                    console.log(matchedObject.groups.month);
                    console.log(matchedObject.groups.day);
                
            

馃挕 Co pojawi si臋 w konsoli ?

RegEXP 10

                
                    const eventDate = /(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})/;

                    const matchedObject = eventDate.exec('2020-06-30');
                    console.log(matchedObject.groups.year);
                    console.log(matchedObject.groups.month);
                    console.log(matchedObject.groups.day);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                      2020,06,30
                    
                

Function

Function 1

                
                    let fn = function showNumber() {

                        return 1;
                    };
                    
                    console.log(fn.name);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Function 1

                
                    let fn = function showNumber() {

                        return 1;
                    };
                    
                    console.log(fn.name);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        showNumber
                    
                

Function 2

                
                    let fn = function() {

                        return 1;
                    };
                    
                    console.log(fn.name);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Function 2

                
                    let fn = function() {

                        return 1;
                    };
                    
                    console.log(fn.name);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        fn
                    
                

Function 3

                
                    let fn = function() {

                        return 1;
                    };
                    let newFn = fn;
                    console.log(newFn.name);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Function 3

                
                    let fn = function() {

                        return 1;
                    };
                    let newFn = fn;
                    console.log(newFn.name);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        fn
                    
                

Function 4

                
                    class ShowNumbers {
                        constructor() {
                    
                        }
                    
                        show() {
                    
                        }
                    }
                    
                    let s = new ShowNumbers();
                    console.log(ShowNumbers.name);
                    console.log(s.show.name);
                
            

馃挕 Co pojawi si臋 w konsoli ?

Function 4

                
                    class ShowNumbers {
                        constructor() {
                    
                        }
                    
                        show() {
                    
                        }
                    }
                    
                    let s = new ShowNumbers();
                    console.log(ShowNumbers.name);
                    console.log(s.show.name);
                
            

馃挕 Co pojawi si臋 w konsoli ?

                    
                        ShowNumbers, show