JS Quiz Exercise Lab

Front End Developers-Lab


(JS) JavaScript
Interview Questions and Anwsers

Practice Before Interview or Quiz

(JS) JavaScript is the programming language that runs in the browser, which is used to build advanced interactive Web sites and applications for secure browser execution.


      JS Quiz Exercise Lab

      What is Javascript?

      JavaScript is the scripting language of the Web.JavaScript is used in millions of Web pages to add functionality, validate forms, detect browsers, and much more.


      What Javascript can do?

      What Javascript can do? As: JavaScript gives HTML designers a programming tool JavaScript can put dynamic text into an HTML page JavaScript can react to events JavaScript can read and write HTML elements.
      - JavaScript can be used to validate data
      - JavaScript can be used to detect the visitor's browser
      - JavaScript can be used to create cookies

      What is a Javascript statement?

      A JavaScript statement is a command to a browser. The purpose of the command is to tell the browser what to do.

      What is the difference between XML and HTML?

      XML is not a replacement for HTML. XML and HTML were designed with different goals:
      1- XML was designed to transport and store data, with focus on what data is.
      2- HTML was designed to display data, with focus on how data looks.
      The difference is
      HTML is about displaying information, while XML is about carrying information.

      What is a javascript object?

      A collection of data containing both properties and methods. Each element in a document is an object. Using the DOM you can get at each of these elements/objects and do some cool sh*t.

      Describe what event bubbling is?

      Event bubbling causes all events in the child nodes to be automatically passed to its parent nodes. The benefit of this method is speed because the code only needs to traverse the DOM tree once.

      Describe what "this" is in JavaScript?

      In JavaScript, 'this' normally refers to the object which 'owns' the method, but it depends on how a function is called.

      What is the difference between == and === ?

      The 3 equal signs mean "equality without type coercion". Using the triple equals, the values must be equal in type as well.

      == is equal to
      === is exactly equal to (value and type)
      0==false // true
      0===false // false, because they are of a different type
      1=="1" // true, auto type coercion
      1==="1" // false, because they are of a different type
      Resources for this answer:

      Where do you place your JavaScript on the page?

      It may depend on what you are using it for. There is some debate on this but generally a good question to ask to get an understanding of the JS knowledge. Answers:

      What is a closure?

      Closures are expressions, usually functions, which can work with variables set within a certain context. Or, to try and make it easier, inner functions referring to local variables of its outer function create closures. Resources for this answer:

      What is Global Namespacing?


                 
      
      "1" + 2 + "3" + 4;
      

      What does the above statement evaluate to?

      • 10
      • 1234
      • 37

      1234


      4 + 3 + 2 + "1"
      

      What does the above statement evaluate to?

      • 10
      • 4321
      • 91

      91


      var foo = 1;
      function bar() {
      	foo = 10;
      	return;
      	function foo() {}
      }
      bar();
      alert(foo);
      

      What is alerted?

      • 1
      • 10
      • Function
      • undefined
      • Error

      1


      function bar() {
          return foo;
          foo = 10;
          function foo() {}
          var foo = 11;
      }
      alert(typeof bar());
      

      What is alerted?

      • number
      • function
      • undefined
      • Error

      Function


      var x = 3;
      
      var foo = {
          x: 2,
          baz: {
              x: 1,
              bar: function() {
                  return this.x;
              }
          }
      }
      
      var go = foo.baz.bar;
      
      alert(go());
      alert(foo.baz.bar());
      

      What is the order of values alerted?

      • 1, 2
      • 1, 3
      • 2, 1
      • 2, 3
      • 3, 1
      • 3, 2

      3, 1


      var x   = 4,
          obj = {
              x: 3,
              bar: function() {
                  var x = 2;
                  setTimeout(function() {
                      var x = 1;
                      alert(this.x);
                  }, 1000);
              }
          };
      obj.bar();
      

      What value is alerted?

      • 1
      • 2
      • 3
      • 4
      • undefined

      4


      x = 1;
      function bar() {
          this.x = 2;
          return x;
      }
      var foo = new bar();
      alert(foo.x);
      

      What value is alerted?

      • 1
      • 2
      • undefined

      2


      function foo(a) {
          alert(arguments.length);
      }
      foo(1, 2, 3);
      

      What value is alerted?

      • 1
      • 2
      • 3
      • undefined

      3


      var foo = function bar() {}; 
      alert(typeof bar);
      

      What value is alerted?

      • function
      • object
      • undefined

      undefined


      var arr = [];
      arr[0]  = 'a';
      arr[1]  = 'b';
      arr.foo = 'c';
      alert(arr.length);
      

      What value is alerted?

      • 1
      • 2
      • 3
      • undefined

      2


      function foo(a) {
          arguments[0] = 2;
          alert(a);
      }
      foo(1);
      

      What value is alerted?

      • 1
      • 2
      • undefined

      2


      function foo(){}
      delete foo.length;
      alert(typeof foo.length);
      

      What value is alerted?

      • number
      • undefined
      • object
      • Error

      Number


      var foo = function foo() {
          console.log(foo === foo);  
      };
      foo();
      

      What is printed in the console?

      • true
      • false
      • ReferenceError

      true


      function aaa() {
          return
          {
              test: 1
          };
      }
      alert(typeof aaa());
      

      What does the above alert?

      • function
      • number
      • object
      • undefined

      undefined


      Number("1") - 1 == 0;
      

      What is the result?

      • true
      • false
      • TypeError

      true


      (true + false) > 2 + true;
      

      What is the result?

      • true
      • false
      • TypeError
      • NaN

      false


      function bar() {
          return foo;
          foo = 10;
          function foo() {}
          var foo = '11';
      }
      alert(typeof bar());
      

      What is alerted?

      • number
      • function
      • undefined
      • string
      • Error

      function


      "1" - - "1";
      

      What is the result?

      • 0
      • 2
      • 11
      • "11"

      2


      var x = 3;
      
      var foo = {
          x: 2,
          baz: {
              x: 1,
              bar: function() {
                  return this.x;
              }
          }
      }
      
      var go = foo.baz.bar;
      
      alert(go());
      alert(foo.baz.bar());
      

      What is the order of values alerted?

      • 1, 2
      • 1, 3
      • 2, 1
      • 2, 3
      • 3, 1
      • 3, 2

      3, 1


      new String("This is a string") instanceof String;
      

      What is the result?

      • true
      • false
      • TypeError

      true


      [] + [] + 'foo'.split('');
      

      What is the result?

      • "f, o, o"
      • TypeError
      • ["f", "o", "o"]
      • [][]["f", "o", "o"]

      "f, o, o"


      new Array(5).toString();
      

      What is the result?

      • ",,,,"
      • []
      • "[]"

      ",,,,"


      var myArr = ['foo', 'bar', 'baz'];
      myArr.length = 0;
      myArr.push('bin');
      console.log(myArr);
      

      What is printed in the console?

      • ['foo', 'bar', 'baz']
      • ['foo', 'bar', 'baz', 'bin']
      • ['bin', 'foo', 'bar', 'baz']
      • ['bin']

      ['bin']


      String('Hello') === 'Hello';
      

      What is the result?

      • true
      • false
      • TypeError

      true


      var x = 0;
      function foo() {
          x++;
          this.x = x;
          return foo;
      }
      var bar = new new foo;
      console.log(bar.x);
      

      What is printed on the console?

      • ReferrenceError
      • TypeError
      • undefined
      • 0
      • 1

      undefined


      "This is a string" instanceof String;
      

      What is the result?

      • true
      • false
      • TypeError

      false


      var bar = 1,
          foo = {};
      
      foo: {
          bar: 2;
          baz: ++bar;
      };
      foo.baz + foo.bar + bar;
      

      What is the result?

      • ReferenceError
      • TypeError
      • undefined
      • NaN
      • 4
      • 5

      NaN


      var myArr = ['foo', 'bar', 'baz'];
      myArr[2];
      console.log('2' in myArr);
      

      What is the result of console.log?

      • true
      • false
      • ReferenceError

      true


      var arr = [];
      arr[0]  = 'a';
      arr[1]  = 'b';
      arr.foo = 'c';
      alert(arr.length);
      

      What value is alerted?

      • 1
      • 2
      • 3
      • undefined

      2


      10 > 9 > 8 === true;
      

      What is the result?

      • true
      • false

      false


      function foo(a, b) {
          arguments[1] = 2;
          alert(b);
      }
      foo(1);
      

      What value is alerted?

      • 2
      • undefined
      • ReferenceError

      undefined


      NaN === NaN;
      

      What is the result?

      • true
      • false
      • TypeError

      false


      What type of object system does JavaScript support?

      Resources for this answer: $(document).ready(function(){ $('.loader img').click(function() { $('.loader img').hide(); \\ $('.loader img').hide(); }); });

      Are you sure you're ready for this Quiz ?

      JavaScript Web Quiz By David Shariff

      Full JavaScript

      Coming up! My E-Book
    1. Windows Vista

      Coming soon

      1. Go to Start then select Connect To.
      2. Wait a moment while your computer searches for all the wireless networks in range. Find somcablewifi from the list of available networks (SSIDs) and click it. Then click Connect.
      3. You will be prompted that you are connecting to an unsecured wireless network. Click Connect Anyway.
      4. Wait a few seconds while your computer acquires an IP address from the somcablewifi network.
      5. The status will display as Connected, signifying you are connected to the somcablewifi network.

      Also, the Wireless Network Connection icon will appear in your computer's system tray at the bottom of the screen near the clock. To display the strength of your connection, just hover over the icon with your mouse.

      Once you've joined our somcable WiFi network manually, your device automatically joins it whenever the network is in range. If more than one previously-used network is in range, your device joins the one last used.

      Sign In to SOMCABLE WiFi

      Once you've connected to the somcablewifi network, simply launch your Web browser and you will be taken to the SOMCABLE WiFi login page.

      • Enter your Somcable.com email address (or username) and password
      • Click Sign In

      After you successfully enter your credentials, you will be directed to the somcable.com home page. From there, you can begin to browse the Internet.

      Technical Support

      Due to the numerous WiFi devices and configurations available, Somcable is only able to confirm that SOMCABLE WiFi is functioning correctly. Somcable does not offer technical support for connecting devices to the Internet. Please refer to the user manual for your device should you require additional assistance.

      Windows 7

      Connect to the SOMCABLE WiFi Network

      1. Open Connect to a Network by clicking the Start button, and then clicking Connect to.
      2. In the Show list, click Wireless.
      3. You'll see a list of the wireless networks currently available.
      4. Click on somcablewifi, and then click Connect.

      Sign In to SOMCABLE WiFi

      Once you've connected to the somcablewifi network, simply launch your Web browser and you will be taken to the SOMCABLE WiFi login page.

      • Enter your Somcable.com email address (or username) and password
      • Click Sign In

      After you successfully enter your credentials, you will be directed to the somcable.com home page. From there, you can begin to browse the Internet.

      Technical Support

      Due to the numerous WiFi devices and configurations available, Somcable is only able to confirm that SOMCABLE WiFi is functioning correctly. Somcable does not offer technical support for connecting devices to the Internet. Please refer to the user manual for your device should you require additional assistance.

      Mac OS X®

      Make Sure WiFi Is Turned On

      WiFi is used on Macs to set up and manage WiFi connections. The WiFi icon is found in the menu bar next to the clock.

        If the icon is empty, WiFi is turned off, or you are not within WiFi range.

        If the icon is filled in, you are currently within WiFi range.

      To turn WiFi on

      1. Click the WiFi icon.
      2. Select Turn WiFi On.

      Connect to the SOMCABLE WiFi Network

      1. Click the WiFi icon.
      2. Find somcablewifi from the list of available networks (SSIDs) and select it.
      3. Wait a few moments while your Mac connects. Once connected, a check mark will appear in the WiFi menu next to the somcableywifi SSID.

      Once you've joined our SOMCABLE WiFi network manually, your device automatically joins it whenever the network is in range. If more than one previously-used network is in range, your device will join the one last used.

      Sign In to SOMCABLE WiFi

      Once you've connected to the somcablewifi network, simply launch your Web browser and you will be taken to the SOMCABLE WiFi login page.

      • Enter your Somcable.com email address (or username) and password
      • Click Sign In

      After you successfully enter your credentials, you will be directed to the somcable.com home page. From there, you can begin to browse the Internet.

      Technical Support

      Due to the numerous WiFi devices and configurations available, Somcable is only able to confirm that SOMCABLE WiFi is functioning correctly. Somcable does not offer technical support for connecting devices to the Internet. Please refer to the user manual for your device should you require additional assistance.

      iPhone® or iPod touch®

      Make sure WiFi is turned on

      1. Tap Settings
      2. Tap WiFi
      3. Make sure WiFi is set to ON. If WiFi is set to OFF, tap the OFF button to turn it on.

      Connect to the SOMCABLE WiFi Network

      Once WiFi is turned on, it is easy to connect to SOMCABLE WiFi. From the iPhone or iPod Touch

      1. Tap Settings
      2. Tap WiFi
      3. Wait a moment as your iPhone or iPod touch detects the WiFi networks in range
      4. Find somcablewifi from the list of available networks (SSIDs) and tap it
      5. Wait a few seconds while your iPhone or iPod touch connects. Once connected, a check mark will appear next to the somcablewifi SSID

      Also, the WiFi icon will appear in your phone's status bar at the top of the screen when it is connected to a WiFi network. It will show connection strength as well. The more bars you see, the stronger your WiFi connection.

      Once you've joined the SOMCABLE WiFi network manually, your iPhone or iPod touch will automatically connect whenever the network is in range of one of SOMCABLE WiFi hotspots. If more than one previously used network is in range, your device will join the one last used.

      Sign In to SOMCABLE WiFi

      Once you've connected to the somcablewifi network, simply launch your Web browser and you will be taken to the SOMCABLE WiFi login page.

      • Enter your Somcable.com email address (or username) and password
      • Click Sign In

      After you successfully enter your credentials, you will be directed to the somcable.com home page. From there, you can begin to browse the Internet.

      Technical Support

      Due to the numerous WiFi devices and configurations available, Somcable is only able to confirm that SOMCABLE WiFi is functioning correctly. Somcable does not offer technical support for connecting devices to the Internet. Please refer to the user manual for your device should you require additional assistance.

      Blackberry®

      Connect to the SOMCABLE WiFi Network

      1. From the Blackberry home screen, select the Menu key
      2. Roll the trackball to the icon for Set Up WiFi and click
      3. Use the trackball to scroll down to the Next button and click.
      4. Select Scan For Networks and click.
      5. Scroll down to somcablewifi from the list of available networks (SSIDs) and click it. You'll see a message that your Blackberry is connecting to somcableywifi
      6. Once your Blackberry connects to somcablewifi, you'll see "Connection Successful!" across the top of the screen. On this screen, you can save somcablewifi as a profile. Select Yes and click Next
      7. Click Finish.

      When you are connected, the WiFi logo across the top of your screen will turn black, and somcablewifi will display on the main screen below the clock.

      Once you've joined the SOMCABLEWiFi network, your Blackberry will automatically connect to it whenever the network is in range.

      Set the Browser to use WiFi

      After you've connected to somcablewifi, you'll need to configure the Blackberry browser to use WiFi as the preferred Internet connection.

      1. Launch the Blackberry's browser.
      2. Press the Menu key to display the browser's menu
      3. Select Options
      4. Select General Properties
      5. Click on the current setting for Default Browser and select WiFi Browser
      6. Press the End button and confirm your choice by clicking Save

      Sign In to SOMCABLE WiFi

      Once you've connected to the somcablewifi network, simply launch your Web browser and you will be taken to the SOMCABLE WiFi login page.

      • Enter your Somcable.com email address (or user name) and password
      • Click Sign In

      After you successfully enter your credentials, you will be directed to the somcable.com home page. From there, you can begin to browse the Internet.

      Setup WiFi as the Preferred Voice Connection

      Some providers will allow you to use WiFi for voice service as well. This will enable you to make phone calls without using cellular plan minutes. Check with your cellular provider to see if this option is available with your plan.

      If so, you can configure your Blackberry to use WiFi as the preferred voice connection. With this, your Blackberry will use your cellular provider's network only when WiFi is unavailable.

      1. While on the Blackberry home screen, select the Menu key
      2. Roll the trackball to the icon for Manage Connections and click
      3. Scroll down to Mobile Network Options and click.
      4. Select Connection Preference and click.
      5. Select WiFi Preferred and click
      6. Press the end button and confirm your choice by clicking Save

      Technical Support

      Due to the numerous WiFi devices and configurations available, Somcable is only able to confirm that SOMCABLE WiFi is functioning correctly. Somcable does not offer technical support for connecting devices to the Internet. Please refer to the user manual for your device should you require additional assistance.

      Windows Mobile 5/6

      Note: Instructions may vary slightly from phone to phone as there are several different versions of Windows Mobile 5 and Windows Mobile. For details about your exact version, please consult your phone's documentation or visit http://www.microsoft.com/windowsmobile.

      Enable WiFi on your Phone

      1. Go to Start then Settings
      2. Select Connections from the tabs across the bottom
      3. Select Comm Manager

      Important Note: On some phones, the Comm Manager is in the Programs folder. Simply go to Start then to Programs and select the Comm Manager icon.

      1. Select the WiFi icon. When WiFi is activated, the icon fills in with green and the "x" mark disappears.

      Connect to the SOMCABLE WiFi Network

      1. Go to Start then Settings
      2. Select Connections from the tabs across the bottom
      3. Select Network Cards
      4. Find somcablewifi from the list of available networks (SSIDs) and select and hold it. Then select Connect
      5. In the next screen, make sure The Internet is selected and click OK
      6. Wait a few seconds while your phone is connecting to the SOMCABLE WiFi network. Once complete, the status will display as Connected
      7. Click OK from the top right section of the screen then close the Settings window with the x in the top-right section of the screen

      Once you've joined the SOMCABLE WiFi network manually, your device automatically joins it whenever the network is in range. If more than one previously used network is in range, your device will join the one last used.

      Sign In to SOMCABLE WiFi

      Once you've connected to the somcablewifi network, simply launch your Web browser and you will be taken to the SOMCABLE WiFi login page.

      • Enter your Somcable.com email address and password
      • Click Sign In

      After you successfully enter your credentials, you will be directed to the somcable.com home page. From there, you can begin to browse the Internet.

      Technical Support

      Due to the numerous WiFi devices and configurations available, Somcable is only able to confirm that SOMCABLE WiFi is functioning correctly. Somcable does not offer technical support for connecting devices to the Internet. Please refer to the user manual for your device should you require additional assistance.

      Android

      Make sure WiFi is turned on

      Note: Your service provider may charge to surf the Web or download data.

      1. First, turn on your phone and start at the main screen
      2. Next, click on the Settings icon
      3. After that, press Wireless & networks followed by Wi-Fi settings
      4. Now, touch Menu followed by Scan in order to find available networks in range
      5. Next, touch somcablewifi to connect.
      6. Finally, look for the wireless indicator icon to verify that your smartphone is connected

      Sign In to SOMCABLE WiFi

      Once you've connected to the somcablewifi network, simply launch your Web browser and you will be taken to the SOMCABLE WiFi login page.

      • Enter your Somcable.com email address (or username) and password
      • Click Sign In

      After you successfully enter your credentials, you will be directed to the somcable.com home page. From there, you can begin to browse the Internet.

      Technical Support

      Due to the numerous WiFi devices and configurations available, Somcable is only able to confirm that SOMCABLE WiFi is functioning correctly. Somcable does not offer technical support for connecting devices to the Internet. Please refer to the user manual for your device should you require additional assistance.

      iPad®

      Ensure WiFi is enabled

      1. Tap Settings
      2. Tap WiFi
      3. Make sure WiFi is set to ON. If WiFi is set to OFF, tap the OFF button to turn it on.
      4. Available WiFi networks appear under "Choose a Network".
      5. Locate and tap somcablewifi.

      Sign In to SOMCABLE WiFi

      Once you've connected to the somcablewifi network, simply launch your Web browser and you will be taken to the SOMCABLE WiFi login page.

      • Enter your Somcable.com email address (or username) and password
      • Click Sign In

      After you successfully enter your credentials, you will be directed to the somcable.com home page. From there, you can begin to browse the Internet.

      Technical Support

      Due to the numerous WiFi devices and configurations available, Somcable is only able to confirm that SOMCABLE WiFi is functioning correctly. Somcable does not offer technical support for connecting devices to the Internet. Please refer to the user manual for your device should you require additional assistance.

      Android

      Ensure WiFi is enabled

      1. Tap Apps in the upper right hand corner
      2. Tap Setting
      3. Tap Wireless & networks
      4. Tap Wi-Fi – Turn on Wi-Fi.
      5. Available WiFi networks appear under "Wi-Fi settings – Set up & manage wireless access points."
      6. Locate and tap somcablewifi.

      Sign In to SOMCABLE WiFi

      Once you've connected to the somcablewifi network, simply launch your Web browser and you will be taken to the SOMCABLE WiFi login page.

      • Enter your Somcable.com email address (or username) and password
      • Click Sign In

      After you successfully enter your credentials, you will be directed to the somcable.com home page. From there, you can begin to browse the Internet.

      Technical Support

      Due to the numerous WiFi devices and configurations available, Somcable is only able to confirm that WiFi is functioning correctly. Somcable does not offer technical support for connecting devices to the Internet. Please refer to the user manual for your device should you require additional assistance.