Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save djD-REK/cc3ecf89ee2acc5f716cf41873935a70 to your computer and use it in GitHub Desktop.
Save djD-REK/cc3ecf89ee2acc5f716cf41873935a70 to your computer and use it in GitHub Desktop.
// Enter these commands into the console to load jQuery first.
// <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
const scriptSource = "https://code.jquery.com/jquery-3.5.0.js"
document.write(`<script src="${scriptSource}" type="text/javascript"></script>`)
// Then, enter the following commands separately:
console.log($) // function jQuery(selector, context)
console.log(typeof $) // "function"
console.log($()) // Object { }
console.log(typeof $()) // "object"
try {
console.log($().jquery) // "3.5.0"
console.log(typeof $().jquery) // "string"
} catch (e) {
console.log(e)
}
// Equivalent to:
try {
console.log(jQuery) // function jQuery(selector, context)
console.log(typeof jQuery) // "function"
console.log(jQuery()) // Object
console.log(typeof jQuery()) // "object"
console.log(jQuery().jquery) // "3.5.0"
console.log(typeof jQuery().jquery) // "string"
} catch (e) {
console.log(e)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment