Last active
March 5, 2019 08:31
-
-
Save kushdilip/be48745d7b18734a2b5e156af82c751d to your computer and use it in GitHub Desktop.
Ember Source Code Reading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `window.ActiveXObject` is "falsey" in IE11 (but not `undefined` or `false`) | |
// `"ActiveXObject" in window` returns `true` in all IE versions | |
// only IE11 will pass _both_ of these conditions | |
declare global { | |
interface Window { | |
ActiveXObject: any; | |
} | |
} | |
export const isIE11 = !window.ActiveXObject && 'ActiveXObject' in window; | |
export const isEdge = /Edge/.test(navigator.userAgent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let isNode = | |
typeof window === 'undefined' && | |
typeof process !== 'undefined' && | |
{}.toString.call(process) === '[object process]'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I have made an attempt to go through ember.js source code. | |
// Below snippets are taken from the same which do specific tasks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creates object with no constructor | |
let empty1 = Object.create(null); | |
// Outputs: undefined | |
console.log(empty2.constructor) | |
let empty2 = {}; | |
// Outputs: ƒ Object() { [native code] } | |
console.log(empty2.constructor) | |
/* | |
* Reference Link | |
* http://adripofjavascript.com/blog/drips/creating-objects-without-prototypes.html | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// check if window exists and actually is the global | |
export default typeof self === 'object' && | |
self !== null && | |
(self as any).Object === Object && | |
typeof Window !== 'undefined' && | |
self.constructor === Window && | |
typeof document === 'object' && | |
document !== null && | |
self.document === document && | |
typeof location === 'object' && | |
location !== null && | |
self.location === location && | |
typeof history === 'object' && | |
history !== null && | |
self.history === history && | |
typeof navigator === 'object' && | |
navigator !== null && | |
self.navigator === navigator && | |
typeof navigator.userAgent === 'string'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment