Skip to content

Instantly share code, notes, and snippets.

@automaticalldramatic
Last active April 9, 2018 10:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save automaticalldramatic/21c5305899e59293b9ec to your computer and use it in GitHub Desktop.
Save automaticalldramatic/21c5305899e59293b9ec to your computer and use it in GitHub Desktop.
All those interviews, gave me a good list of interview questions that people generally ask.

Front end coding challenge

Building a simple Web-Application for Analyzing Web-Sites

The objective is to build a web-application that does some analysis of a web-page/URL.

  • The application should show a form with a text-field thus the user can type in the URL of the webpage being analyzed.
  • Additionally to form should contain a button for sending the input to the server as well as to trigger the server-side analysis process.
  • After processing the results should be shown to the user in terms of a simple table below to the form. The result comprises the following information: ** What HTML version has the document? ** What is the page title? ** How many headings of what level are in the document? ** How many internal and external links are in the document? Are there any inaccessible links and how many? ** Did the page contain a login-form?

In case the URL given by the user is not reachable an error message should appear below the input form. The message should contain the HTTP status-code and some useful error description. Please write a node application handling all the wanted features. HINT: for document analysis consider using a library such as cheerio.js and for the server framework you could use express.js!

If you are more familiar with other frameworks/libraries please feel free to use them.

For the frontend part you can use all the available libraries and frameworks available on the internet.

Please provide the result as a npm package with this content:

  1. The project with all source files
  2. A short text document that lists the main steps of building your solution as well as all assumptions/decisions you made in case of unclear requirements or missing information

I have marked the hot ones and have classified questions now into broad categories

Javascript

  • Difference between call() and apply() ?

  • Why do we need to use call() OR apply()

  • How is ECMAScript different from Javascript?

  • What are some of the interesting methods introduced in ECMAScript 5 ?

Very interesting article by John Resig - http://ejohn.org/blog/ecmascript-5-objects-and-properties/

  • How would you clone an object in Javascript ? Cite your answer without using libraries:
function clone(obj){
	if(obj == null || typeof(obj) != 'object')
		return obj;

	var temp = obj.constructor(); // changed

	for(var key in obj)
		temp[key] = clone(obj[key]);
	return temp;
}
  • Three disadvantages of jQuery ?

  • What are closures ?

Whenever you see the function keyword within another function, the inner function has access to variables in the outer function. That is a closure. A function doesn't have to return in order to be called a closure. Simply accessing variables outside of your immediate lexical scope creates a closure. StackOverflow Reply

function foo(x) {
  var tmp = 3;
  return function (y) {
    alert(x + y + (++tmp));
  }
}
var bar = foo(2); // bar is now a closure.
bar(10);
  • What are the different types of inheritances in Javascript. Explain Classical vs Prototypal ?

  • What is the curry() method in javascript ?

http://stackoverflow.com/questions/5176313/javascript-curry http://stackoverflow.com/a/9058751/1156254

  • What is strict mode in javascript?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/Strict_mode?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FFunctions_and_function_scope%2FStrict_mode

  • What are Asynchronous Module Loaders ?

  • What are some of the Javascript Design Patterns ?

This can serve as good reference http://addyosmani.com/resources/essentialjsdesignpatterns/book/

  • How is JSONP different from JSON?

dataType: jsonp for cross-domain request, that means request to different domain and dataType: json for same domain-same origin request. Read about same origin policy

With JSONP you shouldn't see an ajax request if that's what you're looking for. You should however see a request for the resource because JSONP is used for cross domain calls to pull in data from different domains.

It returns your JSON data wrapped in a function name. jQuery handles the function name behind the scenes and passes the data into your success handler. The data is loaded by dynamically creating a script element with the src attribute pointing to the service being called and then attached to the browser's DOM. Then the browser makes a request to the resource and the web service responds with the callback function and data.

Browsers + DOM + HTML + CSS

  1. What is Semantic HTML ?

http://en.wikipedia.org/wiki/Semantic_HTML

  1. What is graceful degradation and progressive enhancement.

Got a few good articles tagged here -> https://delicious.com/rizwan84/progressive%20enhancement

  1. What is the SAME ORIGIN POLICY

  2. How is paint, repaint different in WebKit, Gecko and Trident. (Find out about Blink just in case. For sometime it will be the same as Webkit)

  3. Different Video formats supported in HTML5 ? Read about flash fallbacks

  4. Differences in Canvas / SVG / Flash

  5. Browser Hacks OR Conditional Stylesheets. What is better and in what scenario ? Man Slash Hack \*/* Slash 9 Hack */9

  6. Where should we place Javascript files - top OR bottom. What are the advantages and disadvantages of either method. Where would you use these (Google webfonts you need to place on top + jQuery down or top)

  7. What are counters in CSS3 ?

  8. What would text-shadow: 0 0 0 be minifeid to using a standard CSS minifier. What error does it show ? How can you fix it ?

  9. How is word-wrap different from white-space ?

  10. What is <pre> ?

  11. How is <b> different from <strong> ?

  12. What are Mixins? How can you pas arguments to Mixins ?

http://oocss.org/spec/css-mixins.html http://sass-lang.com/tutorial.html

  1. What is event bubbling and capturing ?

http://stackoverflow.com/questions/4616694/what-is-event-bubbling-and-capturing

Data Structures / Algorithms

Brushing up on sorting algorithms is always good before a big interview. Also, if you are like me and don't have a fancy computer science degree, getting answers to Hashes and the big O questions would be good.
  • Some sorting algorithms written in Javascript (Google) :

http://www.nczonline.net/blog/tag/computer-science/

NoSQL (Mongo, Redis)

Miscellaneous Links

https://developers.google.com/speed/articles/compressing-javascript

http://darcyclarke.me/development/front-end-job-interview-questions/

http://taligarsiel.com/Projects/howbrowserswork1.htm

@rajatc
Copy link

rajatc commented Apr 12, 2013

document.ready vs window.onload : The ready event occurs after the HTML document has been loaded, while the onload event occurs later, when all content (e.g. images) also has been loaded.The ready event occurs after the HTML document has been loaded, while the onload event occurs later, when all content (e.g. images) also has been loaded.

bind() only applies to the items that we currently have selected in the jQuery object. Elements that weren't there when this code was run to attach the handler won't get the handler.live() applies to all current matching elements, as well as any other we might add in the future ie. This also works for the elements that will be created after the page has been loaded. This makes use of event bubbling.

Closure :A closure is the local variables for a function, kept alive after the function has returned. They are objects and have a scope chain associated with them. The benefit of a closure is in the fact that it retains the scope of the parent execution context. So if we have multiple functions within the lexical scope of one function, the function would have access to the local variables of other function. To sum it up we can nest JavaScript functions one inside another, with multiple levels of nesting and a function can read and write not only its own parameters and local variables but also those of any functions it’s nested in.

Delegate:
Attach a handler to one or more events for all elements that match the selector, now or in the future, based on a specific set of root elements.

In general, it's best to use the delegate() method rather than the live() method.
There are two main reasons underpinning this conclusion:
• Performance. The delegate() method offers better performance and faster execution of your code in benchmarks, primarily because it can be applied to specific DOM elements.
• Chaining. The delegate() also supports chaining, whereas live() currently doesn't.
live() bubbles all the way up, and attaches the handler to the document.

@samarpanda
Copy link

Answer to Shim:
The shim is to enable HTML5 elements to be able to be styled through CSS in Internet Explorer versions less than 9.

@samarpanda
Copy link

Difference between Shim and Polyfill ?

@samarpanda
Copy link

Some more questions Sp Questions v1

@automaticalldramatic
Copy link
Author

GIT INTERVIEW QUESTIONS

I wrote the wrong thing in a commit message

If the commit hasn’t been push you can do the following, which will allow you to edit the message on the most recent commit:

git commit --amend 

How can I undo the last commit?

You can use git reset e.g.:

git reset --hard HEAD~1 

HEAD~1 means HEAD-1 commit. It should be noted that this is the nuclear option, and any changes you made will be discarded. If you want to keep your changes in the working tree use:

git reset --soft HEAD~1 

If you’ve already published your commits, you should use revert. This is create new commits undoing the last change:

git revert HEAD~1..HEAD git revert commitid 

Delete a Git branch remotely

git push origin --delete branchname

What are the differences between ‘git pull’ and ‘git fetch’?

git pull, is git fetch followed by git merge. git fetch gets the remote changes, they get kept under refs/remotes//. However it doesn’t affect your local branches, and won’t change your working copy. git pull then merges these changes with the local copy.

How do I undo a ‘git add’ before committing

You did a “git add filename” accidentally and want to undo it before committing your change. You can simply do:

git reset filename

To unstage your changes to that file.

How do I deal with merge conflicts

Use “git mergetool” which gives a handy interface for solving merge conflicts.

Remove all local untracked files (and directories) from your local clone

Careful! You might want to take a backup before doing this:

git clean -f -d

Clone all remote branches

You probably already have, they’re just hiding! Use the following to see all the branches:

git branch -a

You can then use “git checkout origin/branchname” to take a look at the branch. Or “git checkout -b branchname origin/branchname”. To create a local tracking branch.

Rename local branch?

git branch -m oldname newname

Revert to a previous Git commit

You can use reset as above to revert to a previous commit, this assumes you mean go back to where you were before permanently rather than just take a look (for that you want to checkout an old version). The commit ID, should be as shown in the output of “git log”.

git reset --hard commitid

Again this will discard all changes in your working tree, so make sure this is really what you want to do! Or look at using –soft rather than –hard.

Remove a git submodule

Creating a submodule is pretty straight-forward, but deleting them less so the commands you need are:

git submodule deinit submodulename git rm submodulename git rm --cached submodulename rm -rf .git/modules/submodulename

Over-write local files when doing a git pull

Git reset is your friend again:

git fetch --all git reset --hard origin/master

How can I add an empty directory to my repository?

You can’t! git doesn’t support this, but there’s a hack. You can create a .gitignore file in the directory with the following contents:

Ignore everything in this directory * # Except this file !.gitignore

I don’t believe it actually matters what’s in the .gitignore (and this .gitignore will ignore all files).

git export, exporting the source code as with “svn export”

Use git archive e.g:

git archive --format zip --output /full/path/to/zipfile.zip master

Discard all my unchecked in changes

git checkout -- .

Create a new remote branch from the current local one

git config --global push.default current git push -u

Restore a deleted file

First find the commit when the file last existed:

git rev-list -n 1 HEAD -- filename

Then checkout that file

git checkout deletingcommitid^ -- filename

Revert a single file to a specific previous commit

Similar to the above, but a bit simpler:

git checkout commitid filename

Make git ignore permissions/filemode changes

git config core.fileMode false

Get git to remember my password when checking out with https

It’ll only remember your password for 15mins:

git config --global credential.helper cache

You can make it remember your password longer with:

git config --global credential.helper "cache --timeout=XXXX"

Take a quick look at an old revision of a single file

git show commitid:filename

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment