Skip to main content

Posts

Showing posts with the label TypeScript

How to detect Safari, Chrome, IE, Firefox, and Opera browser in JavaScript?

Let’s see the example, // Opera 8.0+ var isOpera = (!! window . opr && !! opr . addons ) || !! window . opera || navigator . userAgent . indexOf ( ' OPR/' ) >= 0 ; // Firefox 1.0+ var isFirefox = typeof InstallTrigger !== 'undefined' ; // Safari 3.0+ "[object HTMLElementConstructor]" var isSafari = /constructor/ i . test ( window . HTMLElement ) || ( function ( p ) { return p . toString () === "[object SafariRemoteNotification]" ; })(! window [ 'safari' ] || ( typeof safari !== 'undefined' && safari . pushNotification )); // Internet Explorer 6-11 var isIE = /*@cc_on!@*/ false || !! document . documentMode ; // Edge 20+ var isEdge = ! isIE && !! window . StyleMedia ; // Chrome 1 - 71 var isChrome = !! window . chrome && (!! window . chrome . webstore || !! window . chrome . runtime ); // Blink engine detection var isBlink = ( isChr...

Var, Let & Const | What is the difference between let, var, and const?

What is the difference between let, var, and const? In this article, I’m explaining the importance of these three keywords in JavaScript and TypeScript .   I also provided various examples to deeply understand and use them and what happened when? Let see about: V ar vs. Let vs. Const var : - 1.       var is function-scoped 2.       var return undefined when accessing a variable before it's declared let : - 1.       let is block-scoped 2.       let throw ReferenceError when accessing a variable before it's declared const :- 1.       Const is block-scoped 2.       Const throw ReferenceError when accessing a variable before it's declared 3.       Const cannot be reassigned Let see the Examples to understand what happens when - What will happen when the following ...