본문 바로가기

✘✘✘ Javascript25

[javascript] IIFE(immediately invoked function expression) Search: javascript parentheses IIFE tmp=function(){}() +function(){}() -function(){}() 0/function(){}() 0*function(){}() 0?0:function(){}() (function(){}()) (function(){})() Why are parentheses required around JavaScript IIFE? [duplicate]Ask Question There are two ways to create functions in JavaScript (well, 3, but let's ignore new Function()). You can either write a function declaration or.. 2022. 7. 12.
[javascript][event] Detect mouse right click: context menu Is right click a Javascript event? Search: how to detect mouse right click in javascript window.oncontextmenu = function () { alert('Right Click') } $("#myId").mousedown(function(ev){ if(ev.which == 3) { alert("Right mouse button clicked on element with id myId"); } }); javascript detect right click Code Example document.body.onclick = function (e) { var isRightMB; e = e || window.event; if ("wh.. 2022. 7. 5.
Keyboard Event: How to detect keyboard you typed: e.which, e.keycode, e.key, e.charcode, e.code which, keycode, key, charcode, code when I type 'f', charCode: 0 keyCode: 70 key='f' code='KeyF' which: 102 charCode, keyCode: deprecated charCode: Non-standard Reference 2022. 6. 29.
Event vs CustomEvent && How to trigger event with data Event vs CustomEvent CustomEvent can send data through 'detail' property, but Event can not do that; Event const eventInstance = new Event(':eventName'); // add event on document document.addEventListener(':eventName', (e) => { // TODO console.log(e); }); // trigger event document.dispatch(eventInstance);CustomEvent const customEventInstance = new CustomEvent(':custom.. 2022. 6. 27.
Constructor overloading with default 변수 선언 후 생성자에서 할당 class Test { name: string; protected age: number; public id?: string; private password?: string; constructor(name = "", age = 0, id = undefined, password = undefined) { this.name = name; this.age = age; this.id = id; this.password = password; } }생성자에서 선언하고 변수 할당하기 => id, password class Test { name: string; protected age: number; constructor( name: string = "", age: number = 0, p.. 2022. 6. 25.