Skip to main content

JavaScript Questions and Answers - Part 2

Continue random JavaScript Questions and Answers from previous post.

What are difference between global and local variables? 
A variable that is declare outside of a function is a global variable, and its value is accessible and modifiable throughout your program. A variable that is declared inside a function is local. It is created and destroyed every time the function is executed, and it cannot be accessed by any code outside the function. ( msdn.microsoft.com )

How we define a class in JavaScript?
JavaScript does not have a class definition separate from the constructor. Instead, you define a constructor function to create objects with a particular initial set of properties and values. Any JavaScript function can be used as a constructor. You used the new operator with a constructor function to create a new object. ( developer.mozilla.org )

What is a JavaScript function?
JavaScript function is a block of code that will be executed when it was called by external code. A function begin with the function keyword, followed by the name, list of parameters if any, and a block of codes inside a curly braces. Function can return a value. Arguments are passed to function by a value.

What is a function expression?
A function expression is a function defined inside an expression. A function name in function expression can be omitted, in which case the function is anonymous. Example: var foo = function () { return 5; }
Related posts:
JavaScript Questions and Answers – Part 2
JavaScript Questions and Answers

Comments

Popular posts from this blog

Visual Studio 2010 Keyboard Shortcuts

These keyboard shortcuts are helpful. Some of them are not document in Visual Studio 2010 Express, for example: <Ctrl> F5 to run the application without debug <Ctrl> Period or <Ctrl> Space for code completion. <Ctr> <Shift> <B> to build the solution For more download the Visual Studio 2010 Keybinding Posters from Microsoft. Credit:  Visual Studio 2010 Keyboard Shortcuts - ScottGu's Blog DevCurry: 30 Favorite Visual Studio Keyboard Shortcuts

Install Android Development Tools on Ubuntu 12.10 (Quantal Quetzal)

First thing first. Make sure Java Development Kit (JDK) install. Go to Terminal and type 'Java -version' to check. You should see the following: java version "1.7.0_07" OpenJDK Runtime Environment (IcedTea7 2.3.2) (7u7-2.3.2a-1ubuntu1) OpenJDK Server VM (build 23.2-b09, mixed mode) If Java Development Kit is not installed, you can install it from Ubuntu Software Center. Click on Ubuntu Software Center icon from left side bar and search for Java. Here, I selected 'OpenJava JDK 7 runtime' Go to http://www.eclipse.org/downloads/ to download Eclipse Classic 4.2.1 (Juno) Go to your downloads folder and extract it. Move 'eclipse' folder to your home directory. Launch Eclipse 4.2.1 (Juno) from 'eclipse' folder. Install Android Developer Tools (ADT) plugin for Eclipse. Click on Help -> Install New Software and add the URL 'https://dl-ssl.google.com/android/eclipse/' on the input text box next to 'Work with' and click the 'Add

ASP.NET Questions and Answers - Part 2

How can we prevent browser from caching an ASPX page?  Use the SetNoStore method of the HttpCachePolicy class to direct the client not to store the responses in its history. See http://msdn.microsoft.com/en-us/library/system.web.httpcachepolicy.setnostore.aspx In which event are the controls fully loaded? On Load event. ( http://msdn.microsoft.com/en-us/library/system.web.ui.page(v=vs.100).aspx )  The Page object calls the OnLoad method on the Page object, and then recursively does the same for each child control until the page and all controls are loaded. The Load event of individual controls occurs after the Load event of the page. Use the OnLoad event method to set properties in controls and to establish database connections. (http://msdn.microsoft.com/en-us/library/ms178472(v=vs.100).aspx ) How we can force all the validation controls to run? Using Page.Validate() method to instructs any validation controls included on the page to validate their assigned information. Read more at h