Some jQuery and Javascript related questions.
Hi,
I have some jQuery and Javascript related questions. I'll be glad if someone can respond me.
1. Is .fn equals .prototype? If so, why is it named as .fn?
2. What does $ mean as a function prefix or function parameter? e.g:
- $(function() {
- or
- (function($) {
3. Why ;(function() or ;$(function() isn't a syntax error?
4. What does ~ symbol do as a prefix to return? ( ~return something)
5. In an object literal, how can I make `this` refer only the literal, and not the object that is being handled by jQuery?
- var boo = {
- text: "Hello world",
- handle: function() {
- button.html(this.text); //doesn't work, as this is .something object
- }
- };
- $('.something').on('click', boo.handle);
6. What is called as a namespace on Javascript? Can we call `boo` in the above example as a namespace?
Thank you! :)