Posts

Showing posts from May, 2015

Front End Interview Questions

via: h5bp.github.io/Front-end-Developer-Interview-Questions Front-end Job Interview Questions This file contains a number of front-end interview questions that can be used when vetting potential candidates. It is by no means recommended to use every single question here on the same candidate (that would take hours). Choosing a few items from this list should help you vet the intended skills you require. Note:  Keep in mind that many of these questions are open-ended and could lead to interesting discussions that tell you more about the person's capabilities than a straight answer would. Table of Contents General Questions HTML Questions CSS Questions JS Questions Network Questions Coding Questions Fun Questions Getting Involved Contributors How to Contribute License General Questions: What did you learn yesterday/this week? What excites or interests you about coding? What is a recent technical challenge you experienced and how did you solve it? Wh

ID abd Class

ID's are unique Each element can have only one ID Each page can have only one element with that ID Classes are NOT unique You can use the same class on multiple elements. You can use multiple classes on the same element. ID's have special browser functionality If you have a URL like http://yourdomain.com#comments, the browser will attempt to locate the element with an ID of "comments" and will automatically scroll the page to show that element. It is important to note here that the browser will scroll whatever element it needs to in order to show that element, so if you did something special like a scrollable DIV area within your regular body, that div will be scrolled too.

JSONP

JSONP  or " JSON  with padding" is a communication technique used in  JavaScript  programs running in web browsers to request data from a server in a different domain, something prohibited by typical web browsers because of the  same-origin policy . JSONP takes advantage of the fact that browsers do not enforce the same-origin policy on 

What is the difference between call and apply?

The difference is that  apply  lets you invoke the function with arguments as an array;  call requires the parameters be listed explicitly. A useful mnemonic is "A for array and C for comma." See  here  and  here . Pseudo syntax: theFunction.apply(valueForThis, arrayOfArgs) theFunction.call(valueForThis, arg1, arg2, ...) Sample code: function theFunction ( name , profession ) { alert ( "My name is " + name + " and I am a " + profession + "." ); } theFunction ( "John" , "fireman" ); theFunction . apply ( undefined , [ "Susan" , "school teacher" ]); theFunction . call ( undefined , "Claude" , "mathematician" ); via:  http://stackoverflow.com/questions/1986896/what-is-the-difference-between-call-and-apply

What is the difference between a function expression vs declaration in JavaScript?

They're actually really similar. How you call them is exactly the same, but the difference lies in how the browser loads them into the execution context. function declarations loads before any code is executed.  While function expressions loads only when the interpreter reaches that line of code. So if you try to call a function expression before it's loaded, you'll get an error But if you call a function declaration, it'll always work. Because no code can be called until all declarations are loaded.  ex. Function Expression alert ( foo ()); // ERROR! foo wasn't loaded yet var foo = function () { return 5 ; } ex. Function Declaration alert ( foo ()); // Alerts 5. Declarations are loaded before any code can run. function foo () { return 5 ; } Via: http://stackoverflow.com/questions/1013385/what-is-the-difference-between-a-function-expression-vs-declaration-in-javascrip

Difference between script, async and defer

Image
Legend script Let’s start by defining what  script  without any attributes does. The HTML file will be parsed until the script file is hit, at that point parsing will stop and a request will be made to fetch the file (if it’s external). The script will then be executed before parsing is resumed. script async async  downloads the file during HTML parsing and will pause the HTML parser to execute it when it has finished downloading. script defer defer  downloads the file during HTML parsing and will only execute it after the parser has completed.  defer  scripts are also guarenteed to execute in the order that they appear in the document. When should I use what? Typically you want to use  async  where possible, then  defer  then no attribute. Here are some general rules to follow: If the script is modular and does not rely on any scripts then use  async . If the script relies upon or is relied upon by another script then use  defer . If the script is smal

Decreasing Web Page Load Times

Optimize Your Images Know when to use the appropriate file format for your images. Changing to a different file format can dramatically decrease the file size of an image. GIF  is ideal for images with few colors like logos. JPEG  is great for images with lots of colors and details like photographs. PNG  is the choice when you need high quality transparent images. Compress and Optimize Your Content The task of compressing your website content can have a huge impact on reducing load times. When using HTTP compression, all of your web page data is sent in a single smaller file instead of a request that is full of many different files. For more information, see this Wikipedia article on  HTTP Compression . You can also optimize and compress your JavaScript and CSS files by combining them and minifying the source code. Put Stylesheet References at the Top Moving your stylesheet references to the  of your HTML document  helps your pages feel like it is loading faster be

Javascript Null check

You can just check if the  variable  has a  truthy  value or not. That means if ( value ) { } will evaluate to  true  if  value  is not: null undefined NaN empty string ("") 0 false The above list represents all possible  falsy  values in ECMA-/Javascript. Find it in the  specification  at the  ToBoolean  section. Furthermore, if you don't  know  whether a variable exists (that means, if it was  declared ) you should check with the  typeof  operator. For instance if ( typeof foo !== 'undefined' ) { // foo could get resolved and it's defined } If you can be sure that a  variable  is declared at least, you should directly check if it has a  truthy value like shown above. Further read:  http://typeofnan.blogspot.com/2011/01/typeof-is-fast.html